Created
April 26, 2024 02:16
validate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(empty($data_to_db['user_name'])) { | |
$_SESSION['errors']['user_name'] = "User name is required"; | |
} | |
if(empty($data_to_db['user_email'])) { | |
$_SESSION['errors']['user_email'] = "Email is required"; | |
} | |
if( filter_var( $data_to_db['user_email'] , FILTER_VALIDATE_EMAIL) ) { | |
$_SESSION['errors']['user_email'] = "Email is required"; | |
} | |
if (empty($data_to_db['password'])) { | |
$_SESSION['errors']['password'] = "Password is required"; | |
} | |
if(strlen( $data_to_db['password'] ) < 8) | |
{ | |
$_SESSION['errors']['password2'] = "Password must be more than 8 characters in length"; | |
} | |
if( !(preg_match('#[0-9]#', $data_to_db['password'] ) )) | |
{ | |
$_SESSION['errors']['password3'] = "Password must contain at least one number"; | |
} | |
if (!preg_match('/([a-z]{1,})/', $data_to_db['password'] )) { | |
// atleast one lowercase letter | |
$_SESSION['errors']['password4'] = "Password must contain at atleast one lowercase letter"; | |
} | |
if (!preg_match('/([A-Z]{1,})/', $data_to_db['password'] )) { | |
// atleast one uppercase letter | |
$_SESSION['errors']['password5'] = "Password must contain at least one uppercase letter"; | |
} | |
if (!preg_match("/\W/", $data_to_db['password'] )) { | |
$_SESSION['errors']['password6'] = "Password should contain at least one special character"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment