-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.php
118 lines (104 loc) · 4.75 KB
/
signup.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
107
108
109
110
111
112
113
114
115
116
117
<?php
include 'conn.php';
session_start();
$errors = array();
if(isset($_POST['done']))
{
$username = mysqli_real_escape_string($con, $_POST['username']);
$email = mysqli_real_escape_string($con, $_POST['email']);
$mobile = mysqli_real_escape_string($con, $_POST['mobile']);
$password = mysqli_real_escape_string($con, $_POST['psw']);
$cpassword = mysqli_real_escape_string($con, $_POST['cpsw']);
$role = "user";
if($password !== $cpassword){
$errors['password'] = "Confirm password not matched!";
}
$q = " SELECT * FROM user WHERE email = '$email'";
$result = mysqli_query($con, $q);
if(mysqli_num_rows($result) > 0){
$errors['email'] = "Email that you have entered is already exist!";
}
if(count($errors) === 0){
$otp = rand(999999, 111111);
$_SESSION['otp'] =$otp;
$_SESSION['email'] = $email;
$status = "notverified";
$insert_data = "INSERT INTO `user`(`name`, `email`, `mobile`, `password`, `role`, `otp`, `status`) VALUES ('$username','$email','$mobile','$password','$role','$otp','$status')";
$data_check = mysqli_query($con, $insert_data);
if($data_check){
require "C:\wamp64\www\E-Library\PHPMailer\PHPMailerAutoload.php ";
$_SESSION['otp'];
$_SESSION['email'];
$mail = new PHPMailer;
$mail->isSMTP();
$mail ->Host="smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'yummchoco4@@';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
//Recipients
$mail->setFrom('[email protected]');
$mail->addAddress($_SESSION['email']);
$mail->addReplyTo('[email protected]' );
//Content
$mail->isHTML(true);
$mail->Subject = 'Email Verification Code';
$mail->Body = "Your verification code for E-Library is '{$_SESSION['otp']}'";
$mail->AltBody = '';
if($mail->send()){
// echo $_SESSION['email'];
header('location:otp_verification.php');
}
else {
echo"error";
echo $_SESSION['email'];
}
}
exit();
}else{
echo $_SESSION['otp'];
echo '<script> alert("You are already a member of E-Library ") </script>';
}
}else{
$errors['db-error'] = "Failed while inserting data into database!";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
<title>Signup</title>
</head>
<style>
<?php include 'style.css';?>
</style>
<body>
<?php include 'navbar.php';?>
<div class= "container">
<br>
<h1>Signup</h1>
<p class="para"> It's quick and easy</p>
<form action="signup.php" method = "post">
<label for="Name"> Name: </label>
<input type="Name" class="form-control" name="username"placeholder="Enter Your Name " required>
<label for="email">Email:</label>
<input type="email" class="form-control" name="email" placeholder="Enter Email"required>
<label for="Mobile">Mobile:</label>
<input type="tel" class="form-control" name="mobile" placeholder="Enter Mobile Number"required>
<label for="password">Password:</label>
<input type="password" class="form-control" name="psw" placeholder="Enter password"required>
<label for="password">Confirm Password:</label>
<input type="password" class="form-control" name="cpsw" placeholder="Enter password"required>
<br>
<div class="clearfix">
<button type="reset" class="btn btn-outline-success offset-5">Cancel</button>
<button type="submit" name="done" role="button" class="btn btn-outline-success ">Signup</button>
</div>
</form>
</div>
</body>
</html>