pb1uk Posted June 6, 2011 Report Share Posted June 6, 2011 Hi all, I'm having a complete mind blank, sure there is a very simple answer to my soloution, but i just can't find it! Basically i have a registration form. When submitting the form goes to another page to process the information. It successful the info will be entered into the database and the user is redirected to the login page. If there is a problem with the data supplied, e.g. the username chosen has already been taken the page will redirect back to the registration form. What i'm trying to do it make it so the form is automatically filled in with what the user previously entered if that makes sense. If anyone knows how to do this i would be very greatful! Thanks, pb1uk Quote Link to comment Share on other sites More sharing options...
falkencreative Posted June 8, 2011 Report Share Posted June 8, 2011 The way I usually handle that is to use several temporary variables. I'll initially set them to be an empty string, and then when the form is processed, set their values using $_POST[]. For example: <?php // set variables to blank string $temp = ''; if (isset($_POST['submit'])) { // process script $temp = $_POST['temp']; } ?> <form action="" method="POST"> <input name="temp" type="text" value="<?php echo $temp' ?>"> <input type="submit" name="submit"> </form> I usually combine my processing script and my form view like you see above, so one file handles everything, or I will make the processing file the "main" file, and use an include to include the form as necessary. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.