Jump to content

[SOLVED] Form Error Return


ambo

Recommended Posts

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) {

Link to comment
https://forums.phpfreaks.com/topic/144844-solved-form-error-return/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.