Jump to content

Register Form Password Validation Error Message


Glese

Recommended Posts

I am trying to use the new way of validating the entered email in a register form.

 

/* REGISTER FORM */
// check if submit button has been clicked
if (isset($_POST['submit_signup'])) {

// process and assign variables after post submit button has been clicked
$user_email 		= strip_tags(trim($_POST['email']));
$user_email             = filter_var($user_email, FILTER_VALIDATE_EMAIL);

$nickname 			= strip_tags(trim($_POST['nickname']));
$password 			= $_POST['password'];
$repassword 		= $_POST['repassword'];
$month				= $_REQUEST['month'];
$day				= $_REQUEST['day'];
$year				= $_REQUEST['year'];
$dob 				= $year . "-" . $month . "-" . $day;
$find_us_question 	= strip_tags(trim($_POST['find_us_question']));

// connect to database
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);

$check_query = "SELECT * FROM user WHERE nickname = '$nickname'";

$check_connect  = mysqli_query($dbc, $check_query) or die(mysqli_error($dbc));

$check_count =  mysqli_num_rows($check_connect);

        
        
        
        // Check if the email exists twice
        
        $query_get = "SELECT email FROM user WHERE email = '$user_email'";

        $query_run = mysqli_query($dbc, $query_get);

        $num_rows = mysqli_num_rows($query_run);
        
        
        
        
        
        
        
// check if username is already taken
if ($check_count != 0) {
	echo "Username already exists!";
            
                
        } elseif ($num_rows != 0) {
            
            echo "This email address is already registered in the database, you can not register it twice.";
            
            
// check if fields are empty
} elseif (empty($user_email) || empty($nickname) || empty($password) || empty($day) || empty($month) || empty($year)) {
	echo "Please fill out all the fields!";

	// check char length of input data
	} elseif (strlen($nickname) > 30 || strlen($user_email) > 50) {
		echo "Maximum allowed character length for nickname/firstname/lastname are 30 characters!";

	// check password char length
	} elseif (strlen($password) > 25 || strlen($password) < 6) {
		echo "Your password must be between 6 and 25 characters!";

	// check if passwords match with each other						
	} elseif ($password != $repassword) {
		echo "Please make sure your passwords are matching!";

	} else {
	// encrypt password
		$password = sha1($password);

 

I would like to implement now an error message stating something along the lines that the entered email address is not valid, how would I have to do the if statement to check the condition?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.