karimali831 Posted July 25, 2010 Share Posted July 25, 2010 Hi, When a user makes a mistake and they go back to the form, all fields are cleared. How can I make it so that when they go back to the form, the data is still inputted? Here is what I got: if($_POST['name']=="") $error_array[] = 'You must enter a title'; if($_POST['info']=="") $error_array[] = 'You must describe the bug'; if($_POST['filename']=="" || $_POST['filename']==".php") $error_array[] = 'You must specify the filename. e.g. cups.php'; if($_POST['errorlocation']=="" || $_POST['errorlocation']=="http://") $error_array[] = 'You must specify the location of this bug, if not, specify your website'; if(count($error_array)) { $error=implode('<br />• ', $error_array); $showerror = '<div class="errorbox"> <b>Please fix the following error(s):</b><br /><br /> • '.$error.' </div>'; echo $showerror.'<br /><input type="button" class="button" onClick="javascript:history.back()" value="Go Back">'; }else{ mysql_query() } Any help is appreciated, Thanks! Quote Link to comment Share on other sites More sharing options...
freelance84 Posted July 25, 2010 Share Posted July 25, 2010 You can achieve this a number of ways. If the content is not private then you could put the data into the URL. Or you could put the data in SESSION variable. When the check php goes back to the form page, the form page gets the data from where ever you put in it and inputs it into the form fields. e.g. name field $name = ""; if(isset($_GET['name'])) { $name = $_GET['name']; } echo "<input type=\"text\" name=\"name\" value=\"$name\"/>"; 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.