acctman Posted October 15, 2008 Share Posted October 15, 2008 I have two questions about processing a Form, question 1. I have a date drop down menu it has numbers in it, even though only numbers can be processed, should I still validate/check to make sure the value is a number before running my mysql Update query? question 2. When the form is being processed and an invalid entry is found, how do I make the script redirect the user back to the form page? What's the professional way for doing this? $en = array_merge($en, $_POST['add']); $err = ''; if ($en['user'] == '' || $en['pass'] == '' || $en['email'] == '') $err .= 'field is blank below<br>'; Quote Link to comment Share on other sites More sharing options...
xtopolis Posted October 15, 2008 Share Posted October 15, 2008 1) Yes. They don't have to use your form to send values to your site. 2) php: header('Location: yoursite.html'); html: <meta http-equiv="refresh" content="0;URL=yoursite.html" /> javascript: window.location = "yoursite.html"; (i think that's it..) Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 15, 2008 Share Posted October 15, 2008 In addition to what xtopolis wrote, I would also store the post/get data in a session variable so when you go back to the form you can repopulate the form with the users previous entries so they don't have to enter it all over again. Nothing bites more than taking time to fill out a form and forget one little thing only to have the form come up blank and have to re-enter all of the data. Not user-friendly. Quote Link to comment Share on other sites More sharing options...
acctman Posted October 15, 2008 Author Share Posted October 15, 2008 In addition to what xtopolis wrote, I would also store the post/get data in a session variable so when you go back to the form you can repopulate the form with the users previous entries so they don't have to enter it all over again. Nothing bites more than taking time to fill out a form and forget one little thing only to have the form come up blank and have to re-enter all of the data. Not user-friendly. do you have an example of saving to a session and repopulating? Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 15, 2008 Share Posted October 15, 2008 //assume the original post data contained [username="cronix"] $_SESSION['formdata'] = $_POST; //send user back to form if(isset($_SESSION['formdata')) { extract($_SESSION['formdata']); unset($_SESSION['formdata']); } else { $username=""; } //then in your form <input name="username" value="<?php echo $username; ?>" /> //... I didn't test it but it should be close 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.