-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignup1.php
More file actions
181 lines (165 loc) · 6.86 KB
/
signup1.php
File metadata and controls
181 lines (165 loc) · 6.86 KB
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<?php
$showAlert = false;
$showError = false;
$showSuccess = false;
$isValid = true;
$emailError = false;
$nameError = false;
$passwordError = false;
$confpasswordError = false;
$nameValue = "";
$emailValue = "";
$passwordValue = "";
$confpasswordValue = "";
if (isset($_POST['email'])) {
include('config.php');
$name = $_POST['name'];
$email = $_POST['email'];
$password = $_POST['password'];
$confpassword = $_POST['cpassword'];
$nameValue = $name;
$emailValue = $email;
$passwordValue = $password;
$confpasswordValue = $confpassword;
if(empty($name)){
$nameError = true;
$isValid = false;
}
if(empty($email)){
$emailError = true;
$isValid = false;
}
if(empty($password)){
$passwordError = true;
$isValid = false;
}
if(empty($confpassword)){
$confpasswordError = true;
$isValid = false;
}
if($isValid){
if ($password !== $confpassword) {
$showAlert = true;
} else{
$query = mysqli_query($link, "SELECT * FROM `registration` WHERE email = '$email'");
if (mysqli_num_rows($query) > 0) {
$showError = true;
} else {
$stmt = mysqli_prepare($link, "INSERT INTO `registration` (`name`, `email`, `password`, `dt`) VALUES (?, ?, ?, current_timestamp())");
// Bind parameters to the prepared statement
mysqli_stmt_bind_param($stmt, "sss", $name, $email, $password);
// Execute the prepared statement
if (mysqli_stmt_execute($stmt)) {
$showSuccess = true;
} else {
echo "Facing some technical issue sorry for this inconvinience caused!!";
}
// Close the prepared statement
mysqli_stmt_close($stmt);
}
}
$link->close();
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<title>Sign Up</title>
<link rel="shortcut icon"
href="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQmUUSo7THCDrJG629AyXKTeQr1Cl-CpU6jgQ4WD63gmZYyrvU6SrKx17XxiIH7D8z7M_w&usqp=CAU">
<link href='https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css' rel='stylesheet'>
<link rel="stylesheet" href="signup1.css">
</head>
<body>
<?php
if($showAlert) {
echo '
<div class="alert alert-warning alert-dismissible fade show" role="alert">
<strong>Alert!!</strong> Password And Confirm Password Do Not Match
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>';
}
else if($showError) {
echo '
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<strong>Error!!</strong> Email Id Aleready In Use You Can Directly Log In To Our WebSite
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>';
}
else if($showSuccess){
echo '
<div class="alert alert-success alert-dismissible fade show" role="alert">
<strong>Successfull!!</strong> Your Registeration Done Successfully You Can Login To Our WebSite
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>';
}
?>
<div class="container1">
<ul class="navbar">
<div class="icon">
<a href="home.html"><i class='bx bxs-home'></i></a>
</div>
</ul>
</div>
<div class="box">
<div class="container">
<form action="signup1.php" method="post">
<h1>Sign Up</h1>
<div class="name">
<input type="text" name="name" placeholder="Create User Name" value="<?php echo $nameValue; ?>" autocomplete="off">
<?php
if($nameError){
echo '<strong style="color:red;">Name Is Required Field</strong>';
}
?>
<i class='bx bxs-user'></i>
</div>
<div class="email">
<input type="email" name="email" placeholder="Enter Your Email Address" value="<?php echo $emailValue; ?>" autocomplete="off">
<?php
if($emailError){
echo '<strong style="color:red;">Email Is Required Field</strong>';
}
?>
<i class='bx bxs-envelope'></i>
</div>
<div class="password">
<input type="password" name="password" placeholder="Create Password" value="<?php echo $passwordValue; ?>" autocomplete="off">
<?php
if($passwordError){
echo '<strong style="color:red;">Password Is Required Field</strong>';
}
?>
<i class='bx bxs-lock-alt'></i>
</div>
<div class="cpassword">
<input type="password" name="cpassword" placeholder="Confirm Password" value="<?php echo $confpasswordValue; ?>" autocomplete="off">
<?php
if($confpasswordError){
echo '<strong style="color:red;">Confirm Password Is Required Field</strong>';
}
?>
<i class='bx bxs-lock-alt'></i>
</div>
<div class="button">
<button type="submit">Sign Up</button>
</div>
<div class="account">Already Have an Account ?? <a href="login1.php">Log In</a></div>
</form>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr .net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
</body>
</html>