Welcome to WebmasterWorld Guest from 126.96.36.199 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Become a Pro Member
A silly $_POST question Can you include variables in the brackets? lZakl msg:1300344 7:07 pm on Nov 9, 2005 (gmt 0) What I am trying to do is dynamically load a form for updating a text file. In dynamically building my form, I have line number and field number to name the fields. ie.
echo "<input type='text' name='$linecount_$filedcount' value='whatever'>";
When I send this to the next page ... I would like to write to the file like this:
$tempvar = $linecount . "_" . $fieldcount";
fwrite($fh, $_POST[$tempvar] );
Of course I don't even know if a variable in the $_POST array is even possible. Is it?
directrix msg:1300345 7:39 pm on Nov 9, 2005 (gmt 0)
It's fine -- $_POST is just a (superglobal) array. jatar_k msg:1300346 9:46 pm on Nov 9, 2005 (gmt 0)
you could also just run through the $_POST array with a foreach as well, getting the keys at that point, allowing less margin for error. Making sure you build the exact same thing twice can sometimes get a little out of control.
Also before you just start writing vars into files I would clean them first. The general scenario is a perfect one for XSS.