variable variables within $_POST and associative arrays

mcpd

New Member
I'm probably being a little thick, but I can't seem to find an answer to this one. I'm moving from a server with register globals ON to one with it being off. It's a good thing, but unfortunately I have been used to years and years working with register globals being ON which has resulted in me writing sloppy code. I am now trying to fix that.I'm trying to rewrite some old code which has variable variables within $_POST.I know this is a silly example, but it illustrates the problem I am trying to solve. The following would work with register globals ON:\[code\]<?php $variable = "fullname";?><form action="/test/" method="post"><label for="fullname">Full Name:</label> <input name="fullname" type="text" value="http://stackoverflow.com/questions/3585277/<?php echo $$variable;?>" size="20" maxlength="150" /><input name="submit" type="submit" value="http://stackoverflow.com/questions/3585277/Go!" /></form>\[/code\]How do I make this work with register globals off? The following obviously doesn't work:\[code\]<?php $variable = "fullname";?><form action="/test/" method="post"><label for="fullname">Full Name:</label> <input name="fullname" type="text" value="http://stackoverflow.com/questions/3585277/<?php echo $_POST[$$variable];?>" size="20" maxlength="150" /><input name="submit" type="submit" value="http://stackoverflow.com/questions/3585277/Go!" /></form>\[/code\]Please go easy on me- I know I am probably being stupid, but I can't seem to get my head round this.
 
Back
Top