Jump to content

Archived

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

mhoctober

Forgotten Form Data

Recommended Posts

All,

I have a .htm form that collects and submits data to a .php file, which connects to a backend mySQL db and inserts the user data, well - thats what its supposed to do!!

I have verified that the insert statement in the .php file is working fine (to test it I temporarily hard coded some values into it and these were inserted into the backend mySQL table OK).

For some strange reason all the data that the user is entering into the form seems to be forgotten!

Further testing results :

The key field in the mySQL database is set to auto increment, which it does every time the user completes the forms and clicks submit - but no user data is getting stored in the table.

I believe the problem lies somewhere in the form as I have tried echo $first in the .php file and nothing is output to the screen.

Any ideas?

Share this post


Link to post
Share on other sites
[!--quoteo(post=352586:date=Mar 7 2006, 02:45 PM:name=MikeHa)--][div class=\'quotetop\']QUOTE(MikeHa @ Mar 7 2006, 02:45 PM) [snapback]352586[/snapback][/div][div class=\'quotemain\'][!--quotec--]
The key field in the mySQL database is set to auto increment, which it does every time the user completes the forms and clicks submit - but no user data is getting stored in the table.

I believe the problem lies somewhere in the form as I have tried echo $first in the .php file and nothing is output to the screen.
[/quote]

Code! We need code! :)

It *sounds* like the variables are being passed into the script but you're losing them somewhere in there.. Without seeing the source it's gonna be hard to determine what you're doing. Simply put, the variables submitted wind up in 2 of 3 places. If you use a GET method on the form, the $_GET[] hash is populated with the information. If you use POST, then $_POST[] is populated. In both instances, $_REQUEST[] is populated.

So, if you submitted a form using a POST method, and you have a username and a password field, you can access the data like this :

[code]
$username = $_POST['username'];
$password = $_POST['password'];

or

$username = $_REQUEST['username'];
$password = $_REQUEST['password'];
[/code]

And please, code responsibly. Sanitize that data. Don't let that evil skript kiddy hack you!

Share this post


Link to post
Share on other sites
Thanks! That looks like it will do the trick.

To reference the forms variable I was simply using...

$first, $last etc... and not $post['first']

Strange that this has only become a problem since we have migrated the site to a new server. Maybe the new server has an older version of php??

That being the case I wonder how many slices of code I'm going to have to hack!!!

Thanks again...

Mike

[!--quoteo(post=352588:date=Mar 7 2006, 02:52 PM:name=XenoPhage)--][div class=\'quotetop\']QUOTE(XenoPhage @ Mar 7 2006, 02:52 PM) [snapback]352588[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Code! We need code! :)

It *sounds* like the variables are being passed into the script but you're losing them somewhere in there.. Without seeing the source it's gonna be hard to determine what you're doing. Simply put, the variables submitted wind up in 2 of 3 places. If you use a GET method on the form, the $_GET[] hash is populated with the information. If you use POST, then $_POST[] is populated. In both instances, $_REQUEST[] is populated.

So, if you submitted a form using a POST method, and you have a username and a password field, you can access the data like this :

[code]
$username = $_POST['username'];
$password = $_POST['password'];

or

$username = $_REQUEST['username'];
$password = $_REQUEST['password'];
[/code]

And please, code responsibly. Sanitize that data. Don't let that evil skript kiddy hack you!
[/quote]

Share this post


Link to post
Share on other sites

×

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.