$password2 = trim($_POST['password2']);
if (empty($first_name) || empty($last_name) || empty($username) || empty($user_email) || empty($password1) || empty($password2)) {
echo "";
exit();
}
if ($password1 !== $password2) {
echo "";
exit();
}
if (!filter_var($user_email, FILTER_VALIDATE_EMAIL)) {
echo "";
exit();
}
$check_query = "SELECT id FROM students_users WHERE username = ? OR email = ?";
$stmt = $connection->prepare($check_query);
$stmt->bind_param("ss", $username, $user_email);
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows > 0) {
echo "";
// echo "";
$stmt->close();
exit();
}
$stmt->close();
$hashed_password = password_hash($password1, PASSWORD_DEFAULT);
$verification_code = rand(100000, 999999);
date_default_timezone_set("Asia/Calcutta");
$postdate = date("M d, Y h:i:s a");
$insert_user_query = "INSERT INTO students_users (username, password, email, email_verified, verification_code, created,orgpd)
VALUES (?, ?, ?, 0, ?, ?,?)";
$stmt = $connection->prepare($insert_user_query);
$stmt->bind_param("sssiss", $username, $hashed_password, $user_email, $verification_code, $postdate,$password1 );
if ($stmt->execute()) {
$student_users_id = $stmt->insert_id;
$stmt->close();
$insert_student_query = "INSERT INTO students (student_fname, student_lname, student_user_name, student_email, student_users_id, created)
VALUES (?, ?, ?, ?, ?, ?)";
$stmt = $connection->prepare($insert_student_query);
$stmt->bind_param("ssssis", $first_name, $last_name, $username, $user_email, $student_users_id, $postdate);
if ($stmt->execute()) {
$stmt->close();
// $to = $user_email;
// $subject = "Email Verification";
// $message = "
//
//
//
//
//
//
//
//
Hi $first_name,
//
Thank you for registering.
//
//
//
//
// ";
// $headers = "MIME-Version: 1.0" . "\r\n";
// $headers .= "Content-type: text/html; charset=UTF-8" . "\r\n";
// $headers .= "From: info@signefo.co.in";
// if (mail($to, $subject, $message, $headers)) {
// echo "";
// header('Location: index.php');
// } else {
// echo "";
// header('Location: index.php');
// }
// echo "";
header('Location: index.php');
} else {
echo "";
header('Location: index.php');
}
} else {
echo "";
header('Location: index.php');
}
}
//
Thank you for registering. Please use the code below to verify your email:
//
$verification_code
//
If you didn't register, please ignore this email.
?>