Jump to content

[SOLVED] Accessing POST Variables


JaredKnapp

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/125082-solved-accessing-post-variables/
Share on other sites

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.

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.

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'];

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.