kwdelre Posted February 10, 2011 Share Posted February 10, 2011 Hi there, I am working on getting my php form validation working. I just learned why mine wasn't working and it was because I had a header(location) in the middle of the html doc. The reason I had it there was because the code I am using is placed where I want the error to show. Here is the code I am using for this part. I only have one field being validated at the moment. <? session_start(); if ($_POST['submit']) { $_SESSION['City'] = $_POST['City']; $errors = ""; if(!$_SESSION['City']){ $errors = $errors . "Please enter your city<br>"; } if ($errors != "") { echo "Please check the following errors:<br>"; echo $errors; } else { header("Location: nextpage.php"); } } ?> My question is: What way would you reorganize this (scrapy) validation to where I can redirect my user to a new page when there is no error value? The form page submits to itself with POST. Thanks for your help. Link to comment https://forums.phpfreaks.com/topic/227290-help-with-validation/ Share on other sites More sharing options...
kwdelre Posted February 10, 2011 Author Share Posted February 10, 2011 NEVERMIND I got it....I'm such an amateur! Now I have a different question. My form validation works and all but as I'm testing it ($_POST['submit']) is staying true even when I refresh the page. I have to close Safari and reopen it. What can I do to stop this? Is it just because I am using a testing server? I am using Safari because firefox won't display my php pages. and I am using Xampp Thanks! Link to comment https://forums.phpfreaks.com/topic/227290-help-with-validation/#findComment-1172398 Share on other sites More sharing options...
kwdelre Posted February 10, 2011 Author Share Posted February 10, 2011 Can anyone please help? I am not getting paid for this. I have spent 13 hours now on this stupid validation. PLEASE! Link to comment https://forums.phpfreaks.com/topic/227290-help-with-validation/#findComment-1172433 Share on other sites More sharing options...
atrum Posted February 10, 2011 Share Posted February 10, 2011 at the end of the script unset($_POST['submit']); Link to comment https://forums.phpfreaks.com/topic/227290-help-with-validation/#findComment-1172436 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.