Jump to content


Photo

Forgotten Form Data


  • Please log in to reply
2 replies to this topic

#1 mhoctober

mhoctober
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 07 March 2006 - 07:45 PM

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?


#2 XenoPhage

XenoPhage
  • Members
  • PipPipPip
  • Advanced Member
  • 99 posts

Posted 07 March 2006 - 07:52 PM

[!--quoteo(post=352586:date=Mar 7 2006, 02:45 PM:name=MikeHa)--][div class=\'quotetop\']QUOTE(MikeHa @ Mar 7 2006, 02:45 PM) View Post[/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 :

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

or

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

And please, code responsibly. Sanitize that data. Don't let that evil skript kiddy hack you!
--
[a href=\"http://blog.godshell.com\" target=\"_blank\"]XenoPhage[/a]
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Something mysterious is formed, born in the silent void. Waiting alone and unmoving, it is at once still and yet in constant motion. It is the source of all programs. I do not know its name, so I will call it the Tao of Programming.[/quote]

#3 mhoctober

mhoctober
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 07 March 2006 - 08:35 PM

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) View Post[/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 :

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

or

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

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





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users