-
Notifications
You must be signed in to change notification settings - Fork 1
/
signup_verify_app.php
executable file
·106 lines (88 loc) · 4.41 KB
/
signup_verify_app.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php require_once("includes/session.php");?>
<?php require_once("includes/db_connection.php");?>
<?php require_once("includes/functions.php");?>
<?php
if(isset($_POST["username"])&&isset($_POST["name"])&&isset($_POST["email"])&&isset($_POST["password"]))
{
$count_query="SELECT count FROM live WHERE id = '1'";
$result_countquery=mysqli_query($conn,$count_query);
$cr=mysqli_fetch_assoc($result_countquery);
$ucr=$cr['count']+1;
$updatec_query="UPDATE live SET count='{$ucr}' WHERE id = '1'";
$result_ucountquery=mysqli_query($conn,$updatec_query);
$sname=$_POST['name'];
$username=$_POST['username'];
$email=$_POST['email'];
$password=$_POST['password'];
$query_ucheck = "SELECT username FROM users WHERE username = '{$username}'";
$result_ucheck = mysqli_query($conn, $query_ucheck);
$query_echeck = "SELECT email FROM users WHERE email = '{$email}'";
$result_echeck = mysqli_query($conn, $query_echeck);
if (mysqli_num_rows($result_ucheck) !=0)
{
$q="username_exists";
$data_array = array(
"success" => $q,
);
$output=json_encode($data_array);
print($output);
//echo "Username already exists";
}
else if(mysqli_num_rows($result_echeck)!=0)
{
$q="email_exists";
$data_array = array(
"success" => $q,
);
$output=json_encode($data_array);
print($output);
//echo "Email already exists";
}
else
{
$retval1 = ereg("(@vit.ac.in$)", $email);
$retval2 = ereg("(^@vit.ac.in)", $email);
if( $retval1 == true && $retval2==false )
{
$hashed_password = password_encrypt($password);
$confirmcode = rand();
//$confirmcode = MD5($email."&*@dhv1%!@90!124^%&>>?".$username);
$ectstamp=time();
$query = "INSERT INTO users (sname, username, email, hashed_password, confirmed, confirm_code,ectstamp)";
$query .= " VALUES ('{$sname}', '{$username}', '{$email}', '{$hashed_password}', '0', '{$confirmcode}','{$ectstamp}')";
$result = mysqli_query($conn, $query);
if ($result) {
$found_user = attempt_login($username, $password);
if ($found_user) {
// $header= array(
// 'From: [email protected]',
// 'Content-Type: text/html'
// );
// $html = '<html lang="en"><head><meta charset="UTF-8"><title>Document</title><style>.hello{font-size: 15px;}</style></head><body><div class="hello"><h1>Hello H1</h1></div></body></html>';
// $message = $html. "Confirm your email by clicking the link http://cambuzz.co.in/emailconfirm.php?username=$username&code=$confirmcode";
$message = "Confirm your email by clicking the link http://cambuzz.co.in/emailconfirm.php?username=$username&code=$confirmcode";
mail($email, "Confirm your email", $message, "From: [email protected]");
$q="true";
$data_array = array(
"success" => $q,
);
$output=json_encode($data_array);
print($output);
// echo "Kindly check your VIT email and confirm your registration after closing this signup form.<br /><span style='color:red;'>Your link will be expired in 30 minutes.</span>";
// echo "<br>";
// echo"(Check your spam folder if you don't find it in your inbox.)";
}
}
}
else{
$q="only_vit";
$data_array = array(
"success" => $q,
);
$output=json_encode($data_array);
print($output);
// echo "Only VIT email is recognised";
}
}
}
?>