-
Notifications
You must be signed in to change notification settings - Fork 1
/
signup_verify.php
executable file
·65 lines (58 loc) · 3.16 KB
/
signup_verify.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
<?php require_once("includes/session.php");?>
<?php require_once("includes/db_connection.php");?>
<?php require_once("includes/functions.php");?>
<?php require_once("includes/validation_functions.php"); ?>
<?php
if (logged_in()) {
redirect_to ("public/Inside/buzz.php");
}
?>
<?php
$sname = $_POST['name'];
$username = mysql_prep($_POST["register"]);
$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) {
echo "Username already exists";
}
else if(mysqli_num_rows($result_echeck)!=0)
{
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]");
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{
echo "Only VIT email is recognised";
}
}
?>