please enter your email";
else if (!(filter_var($_POST['email'], FILTER_VALIDATE_EMAIL))) $error.="
please enter a valid email";
if(!$_POST['password']) $error.="
please enter your password";
if(!$_POST['username']) $error.="
please enter your username";
if(!$_POST['phone']) $error.="
please enter your phone number";
if(!$_POST['pin']) $error.="
please enter your Location Pin";
//Check the validite of PassWord
else {
if(strlen($_POST['password'])<8) $error.="
please enter at least 8 caracters password";
if(!preg_match('`[A-Z]`', $_POST['password']))$error.="
please enter at least one capital letter in password";
}
//phone validation
$phone=$_POST['phone'];
$numberOfDigits = strlen($phone);
//if number was 10 caracters
if (!($numberOfDigits == 10)) {
$error.="
please enter 10 caracters in the phone number";}
//if number was from algerian company
$company=$phone/100000000;
if(!($company==05) OR !($company==07) OR !($company==06)){
$error.="
please enter a phone number start with 05,07 or 06";
}
//Print the Errot If there is an error
if($error) echo '
There is a error
' .$error. '
';
//If there is not a error ...
else{
//Connect With the DataBase and Check if the email was reister before in DataBase
$query ="SELECT * FROM `user` WHERE email='".mysqli_real_escape_string($link ,$_POST['email'])."'";
$result= mysqli_query($link, $query);
$results= mysqli_num_rows($result);
//Tell the user a message if hisregister before
if($results) echo '
There is a error
that email address is already registered
';
//If he don't register Before ...
else {
$username=$_POST['username'];
$email=mysqli_real_escape_string($link ,$_POST['email']);
$phone=$_POST['phone'];
$pass=$_POST['password'];
$pin=$_POST['pin'];
$query="INSERT INTO `user` (`user_id`,`username`,`email`,`phone`, `pass`,`pin`)VALUES(NULL,'$username','$email','$phone','$pass','$pin')";
mysqli_query($link, $query);
$_SESSION['id']=mysqli_insert_id($link);
//redirect to login page
header("location:login.php");
}
}
}
?>