homepage Welcome to WebmasterWorld Guest from 54.196.168.78
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved