PRG_Jughead Posted September 13, 2007 Share Posted September 13, 2007 there is the registration form, User inputs the value and submit the form. Processing of the user inputs is done in the next page and if the user inputs are not correct it redirects into registration form. The Problem is that the registration form is displayed with error message But the previously inputted value are not there. The user input must be preserved. How can i do it ?? Quote Link to comment Share on other sites More sharing options...
Psycho Posted September 13, 2007 Share Posted September 13, 2007 You need to have the form post back to the same page. Then use a switch to determine if data was posted. If data was posted attempt to verify data. If verification passes, process the data and then redirect to a confirmation page. If verification passes then show the form. The fields in the form shouls always show the values of the input fields by default. If it is the first load of the page, then those values would be blank. <?php if (isset($_POST['submit'])) { //Do the verification $errors = false; if (isempty($_POST['field1'])) { $errors = "Field 1 cannot be blank"; } } if ($errors == false) { //Process the data then redirect to confirmation page //processing script header("Location: confirmation.php"); } //Show the form ?> <form name="test" method="POST"> Field 1: <input type="text" name="field1" value="<?php echo $_POST['field1']; ?>"> <button name="submit" type="submit">Submit</button> </form> 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.