$fullname = $_POST['fullname'];
$email = $_POST['email'];
$code = $_POST['password'];
$phone_number = $_POST['gender'];
$job = $_POST['job'];
$password = $_POST['password'];
$password = md5($password); //Password Encrypted
if (!empty ($fullname) || !empty($email) || !empty($code) || !empty($phone_number) || !empty($job) || !empty($password)) {
$host = "localhost";
$username = "root";
$dbpassword = "";
$dbname = "final_project";
//create connection here
$conn= new mysqli($host,$username,$dbpassword,$dbname);
if (mysqli_connect_error()) {
die('Connect Error('.mysqli_connect_errno().')'.mysqli_connect_errno());
}else{
$SELECT = "SELECT email from register where email = ? Limit 1";
$INSERT = "INSERT into register (fullname,email,code,phone_number,job,password) value(?,?,?,?,?,?)";
//Prepaired Statement
$stmt = $conn->prepare($SELECT);
$stmt->bind_param("s",$email);
$stmt->execute();
$stmt->bind_result($email);
$stmt->store_result();
$rnum = $stmt->num_rows;
if ($rnum==0) {
$stmt-> close();
$stmt = $conn->prepare($INSERT);
$stmt->bind_param("ssssii", $fullname,$email,$code,$phone_number,$job,$password);
$stmt->execute();
echo "Sign up Successfully!";
}else{
echo "Someone registered with this email";
}
$stmt->close();
$conn->close();
}
}else{
echo "All field are required!";
die();
}
?>