Viewing file: signup_action.php (4.07 KB) -rw-rw-r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
require("connection.php");
include 'functions.php';
session_start();
if ($_REQUEST["otp"]) {
$get_otp = $_REQUEST["otp"];
$user_id = $_SESSION['u_id'];
$update = "update user_details set status='1' where otp='$get_otp' AND user_id='$user_id'";
$result1 = $con->query($update);
if ($result1) {
$get_details = "SELECT user_id, name, otp FROM user_details WHERE otp='" . $get_otp . "' AND user_id='$user_id'";
$get_details1 = mysqli_query($con, $get_details) or die("database error:" . mysqli_error($con));
$count_otp = $get_details1->num_rows;
if ($count_otp > 0) {
while ($row = $get_details1->fetch_assoc()) {
$_SESSION['user_id'] = $row['user_id'];
$_SESSION['user_name'] = $row['name'];
$success = "Registration Successfull!";
if ($_SESSION['course_type']) {
echo 2;
//header("location:dashboard1.php?type=".$_SESSION['course_type']);
} else {
echo 1;
//header("location:dashboard.php?success=".$success);
}
}
} else {
$sql = "DELETE FROM `user_details` WHERE `user_id`='$user_id' AND `status`='0'";
$con->query($sql);
echo 0;
//$otp = "Invalid OTP!";
//header("location:index.php?invalid=".$otp);
}
}
} else {
$name = $_POST["name"];
$email = $_POST["email"];
$phone = $_POST["phone"];
$course_type = $_POST["course_type"];
$_SESSION['course_type'] = $course_type;
// generate OTP
$otp = rand(100000, 999999);
$check = "SELECT email, phone,status FROM user_details WHERE email='" . $email . "' or phone='".$phone."'";
$check = mysqli_query($con, $check) or die("database error:" . mysqli_error($con));
$count = $check->num_rows;
if ($count == 0) {
$query = "insert into user_details(`name`,`email`,`phone`,`otp`)
values('$name','$email','$phone','$otp')";
$result = $con->query($query);
$count = $con->affected_rows;
if ($count > 0) {
$userid=$con->insert_id;
$suser="select * from tb_user where phone='$phone'";
$ruser=$con_it->query($suser);
$rcount=$ruser->num_rows;
if($rcount==0){
$query1 = "insert into `tb_user`(`user_name`,`user_emailid`,`phone`,`user_status`)
values('$name','$email','$phone','srishti_campus')";
$result1 = $con_it->query($query1);
$scount = $con_it->affected_rows;
}
//sending mail
$to = $email;
//$from_email = "neenatr.sics@gmail.com";
$subject = 'Campus Registration';
$title = 'Welcome to Srishti Campus!';
$message = 'Dear ' . $name . ',<br><br><p> You have successfully registered with Srishti Campus.</p>
<b><p>Your Username : ' . $email . ' Or' . $phone . '</p>
<p>OTP : ' . $otp . '</p><br><br>
<p> This is a system generated email, please do not reply back to this email. For more questions please contact us in srishticampusteam@srishtis.com</p>
Thanks,<br>Team Srishti Campus';
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: <srishticampusteam@gmail.com>' . "\r\n";
//$headers .= 'Cc: myboss@example.com' . "\r\n";
mail($to, $subject, $message, $headers);
$messagephone='Dear '.$name.', You have successfully registered with Srishti Campus. Please use OTP '.$otp.' to login to your Srishti Campus account. This OTP can be used only once. Please DO NOT disclose it to anyone.';
send_otp_sms($phone, $messagephone,'signup');
$_SESSION['u_id'] = $userid;
echo 1;
} else {
echo 2;
}
} else {
echo 0;
}
}
?>
|