Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Variable variables" through POST 1

Status
Not open for further replies.

OsakaWebbie

Programmer
Feb 11, 2003
628
JP
I wrote some code a long time ago that I now can't remember why it worked, and can't get it to work again now that I'm on a new hoster who has different settings and different versions of stuff.

The old code depended on register_globals (yes, I know that's a bad idea, but the application is really big, old, and doesn't keep data that is particularly important to protect, so I haven't taken the time to upgrade it all yet). The spot I'm having trouble with does a tricky thing with the incoming POST variables, and that's the problem. In the file with the form, there are lots of inputs like this:
Code:
<input type=checkbox name="237">
The number corresponds to the ID number for a record in my database. A list of all the numbers is also passed to the processing script. In the processing script, I loop through the numbers, assigning them to a simple variable called $sid. Then I take action based on the checked state of the corresponding checkbox, with code like this:
Code:
if ($$sid && other stuff) do something...
The double $$ looks weird, but with register_globals on, it worked - if the checkbox had been checked, the expression evaluated true. But when I try to change it to $_POST['$sid'] it doesn't work - I always get nothing for the value, as if no checkboxes were ever checked. How can I accomplish what I need?
 
Thanks! I don't think the key was the type of quotes - I have always used single quotes for super-global indexes with no problem. But since the index in this case is not a literal but a variable, I shouldn't have been using any quotes at all. I took them out and voila!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top