JaredKnapp Posted September 20, 2008 Share Posted September 20, 2008 I have a PHP site written by someone else that has been running for a long time. Unfortunately, I need to move this site to a new server. One of the interesting features of this site is that when a form is submitted, the Action PHP page has access to the $ variables from the form. For example, the field <input type='text' name='firstname' /> results in a field called $firstname This is not working on the new site. Does anyone know how this could be working on the old site? What do I need to do or install to make this work? Quote Link to comment Share on other sites More sharing options...
DamienRoche Posted September 20, 2008 Share Posted September 20, 2008 You have to use a post function. so put that input into the variable: $firstname = $_POST['firstname']; Of course, the form will have to have have method="post" and action="relevantfile.php" Hope that helps. Quote Link to comment Share on other sites More sharing options...
barrylee Posted September 20, 2008 Share Posted September 20, 2008 has the post value been passed into the variable? ie, $firstname = $_POST['firstname']; otherwise $firstname will be an empty variable Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted September 20, 2008 Share Posted September 20, 2008 I think you may be referring to register_globals (correct me if I'm wrong. ). If you could access the variable without using $_POST then register_globals were turned ON. It's better to leave them off. Quote Link to comment Share on other sites More sharing options...
JaredKnapp Posted September 20, 2008 Author Share Posted September 20, 2008 I think that's it! The site is working on the old server, and is not working on the new server. The code is exactly the same. Magically (I SWEAR) the variables appear without being set. They are just there for use. I'll test, and see what happens.... Thanks for all the responses. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted September 20, 2008 Share Posted September 20, 2008 The code is dependent on register_globals being on to "magically" populate program variables from post data. Unfortunately, register_globals were a huge security blunder and allowed session variables to also be magically set to values that hackers put on the end of urls as get data. Register_globals were turned off 6 years ago. No code written after 2002 should have relied on register_globals. Register_globals have been completely removed in upcoming php6. To fix this you will need to modify the code to set your program variable from the correct $_POST['firstname'] variable where the data is actually at - $firstname = $_POST['firstname']; Quote Link to comment Share on other sites More sharing options...
JaredKnapp Posted September 20, 2008 Author Share Posted September 20, 2008 SOLVED - register_globals Looks like I have a lot of work to do! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.