Welcome to WebmasterWorld Guest from 23.22.250.113

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

A silly $_POST question

Can you include variables in the brackets?

     

lZakl

7:07 pm on Nov 9, 2005 (gmt 0)

10+ Year Member



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

7:39 pm on Nov 9, 2005 (gmt 0)

10+ Year Member



It's fine -- $_POST is just a (superglobal) array.

jatar_k

9:46 pm on Nov 9, 2005 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month