Setting the value to $_POST?


#1

Hey guys,
I’m currently working on a register php file and I’m wondering if it’s possible to have the value for my username and email fields in my form, to be equal to the GET_POST value they entered. I want this because if they fail the validation rules then the page resets and all the fields are automatically cleared and I can see it as something which would annoy my users.
Anyone know how to? ::slight_smile:


#2

Yes, there are many many ways to do this. First, you can just create copies of these fields and hide them.
This basically means you can load the value of a hidden field with the posted values. Something like:

Then the real code in the page would pull the userid from the posted variable.
When the new page was posted on to another page, it would post the $useridcopy to that page for use.

OR, another way which is my favorite way to do this is to just use SESSION variables.
To use them, you put this line: session_start(); at the top of every page and use variables which are passed to every page. So, when someone logs in, you save the $userID variable inside of a session variable something like this: $_SESSION[‘saveduserid’]=$userID; Then, it is available on EVERY page that has the session start command. It is emptied once the browser is closed, you change the value or you “unset” it. If used, you do not need to save the variable anywhere, it is saved on the server until you close the session…

Hope one of those two helps. Let us know which you go with and if you can’t figure them out…
Good luck…