Forward variables to the next page?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Forward variables to the next page?

Post by Stryks »

Hi,

What I have is a registration form, which when submitted goes to a php script which then validates the data (checks lengths and makes sure no invalid chars are used, checks validity of email addy, etc) and if it is valid it submits the data to mysql, an account is made, and you go to the next page.

If it is not valid, it sends you back to the calling form so you can fill it in properly. I would like to carry the correct values across to the calling form should something be wrong, to help speed up the re-entry.

Is this possible, and if so, how?

Thanks
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

If you make the registration page and the validation page the same page, you don't need to worry about this!

Upon successful validation (if no errors) header() to the next page, else show the errors and auto-fill the text boxes with the $_POST data.
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Post by Stryks »

That makes good sense. :)

How would I use the $_POST values to autofill the fields though?

Through the forms elements 'value' property?
microthick
Forum Regular
Posts: 543
Joined: Wed Sep 24, 2003 2:15 pm
Location: Vancouver, BC

Post by microthick »

right.

<input type="text" name="firstname" value="<?= $_POST["firstname"] ?>">
Post Reply