ambo Posted February 11, 2009 Share Posted February 11, 2009 I was trying to post the form data when theres an error back to the register page and fields filled out again //Post Variables $username = $_POST["uname"]; $password = $_POST["password1"]; $password2 = $_POST["password2"]; $email = $_POST["email"]; $fname = $_POST["fname"]; $lname = $_POST["lname"]; $state = $_POST["state"]; $steamid = $_POST["steamid"]; $ulevel = $_POST["ulvl"]; $uid = 0; $passmd5 = md5("$password"); // checks if the email is in use if (!get_magic_quotes_gpc()) { $_POST['email'] = addslashes($_POST['email']); } $emailcheck = $_POST['email']; $checkemex = mysql_query("SELECT email FROM users WHERE email = '$emailcheck'") or die(mysql_error()); $checkem = mysql_num_rows($checkemex); if(strlen($username) < 5){ $readyForm = false; echo "Sorry, the username ".$_POST['uname']." is less than 5 characters."; } ; if(strlen($username) > 30){ $readyForm = false; echo "Sorry, the username ".$_POST['uname']." is less more than 30 characters.')"; } //if the name exists it gives an error if ($checkem != 0) { $readyForm = false; die('Sorry, the email '.$_POST['email'].' is already in use.'); } // checks if the username is in use if (!get_magic_quotes_gpc()) { $_POST['username'] = addslashes($_POST['username']); } $usercheck = $_POST['username']; $checkusex = mysql_query("SELECT username FROM users WHERE username = '$usercheck'") or die(mysql_error()); $check2 = mysql_num_rows($checkusex); //if the name exists it gives an error if ($check2 != 0) { $readyForm = false; die('Sorry, the username '.$_POST['username'].' is already in use.'); } // this makes sure both passwords entered match if ($_POST['password1'] != $_POST['password2']) { $readyForm = false; die('Your passwords did not match. '); } if($readyForm = true) { Quote Link to comment https://forums.phpfreaks.com/topic/144844-solved-form-error-return/ Share on other sites More sharing options...
premiso Posted February 12, 2009 Share Posted February 12, 2009 Store the post variables in SESSSION on the register page check the session variables which may be populated, if isset print them out. So they do not lose the form data. I would suggest making them re-enter their password no matter what error. Quote Link to comment https://forums.phpfreaks.com/topic/144844-solved-form-error-return/#findComment-760154 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.