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?

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.