-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.php
167 lines (138 loc) · 9.04 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
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
<?php
/**
* SignUp Page
* Author: Afeedh Shaji
* Handle: @afeedh
*/
require('./db/conn.php');
?>
<!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://unpkg.com/tailwindcss@^2/dist/tailwind.min.css">
<script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.x.x/dist/alpine.js" defer></script>
<title>Sign Up</title>
</head>
<body>
<div class="min-h-screen flex items-center justify-center bg-gray-50 py-12 px-4 sm:px-6 lg:px-8">
<div class="container lg:max-w-lg mx-auto flex-1 flex flex-col items-center justify-center px-2">
<img class="mx-auto h-16 w-auto mb-5" src="./static/svg/libri_border_wide.svg" alt="Workflow">
<form class="bg-white p-6 lg:p-12 rounded-3xl shadow-lg text-black w-full"
x-data="{password: '',password_confirm: ''}" method="POST">
<h1 class="mb-8 text-center text-3xl font-extrabold text-gray-900">Create an account</h1>
<input type="text"
class="w-full mb-4 px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-b-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm"
name="name" placeholder="Full Name" required />
<input type="text"
class="w-full mb-4 px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-b-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm"
name="rollno" placeholder="Roll Number" required />
<input type="text"
class="w-full mb-4 px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-b-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm"
name="email" placeholder="Email" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$" required />
<input type="text"
class="w-full mb-4 px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-b-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm"
name="phoneno" placeholder="Phone Number" pattern="^\d{10}$" required />
<select name="category" id="category"
class="bg-transparent w-full mb-4 px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-b-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm">
<option value="GEN">General</option>
<option value="OBC">OBC</option>
<option value="SC">SC</option>
<option value="ST">ST</option>
</select>
<input type="password"
class="w-full mb-4 px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-b-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm"
name="password" placeholder="Password" x-model="password" required />
<input type="password"
class="w-full mb-4 px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-b-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm"
name="confirm_password" placeholder="Confirm Password" x-model="password_confirm" required />
<div class="flex mb-4 justify-start ml-4 p-1">
<ul>
<li class="flex items-center py-1">
<div :class="{'bg-green-200 text-green-700': password == password_confirm && password.length > 0, 'bg-red-200 text-red-700':password != password_confirm || password.length == 0}"
class=" rounded-full p-1 fill-current ">
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path x-show="password == password_confirm && password.length > 0"
stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M5 13l4 4L19 7" />
<path x-show="password != password_confirm || password.length == 0"
stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M6 18L18 6M6 6l12 12" />
</svg>
</div>
<span
:class="{'text-green-700': password == password_confirm && password.length > 0, 'text-red-700':password != password_confirm || password.length == 0}"
class="font-medium text-sm ml-3"
x-text="password == password_confirm && password.length > 0 ? 'Passwords match' : 'Passwords do not match' "></span>
</li>
<li class="flex items-center py-1">
<div :class="{'bg-green-200 text-green-700': password.length > 7, 'bg-red-200 text-red-700':password.length < 7 }"
class=" rounded-full p-1 fill-current ">
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path x-show="password.length > 7" stroke-linecap="round" stroke-linejoin="round"
stroke-width="2" d="M5 13l4 4L19 7" />
<path x-show="password.length < 7" stroke-linecap="round" stroke-linejoin="round"
stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</div>
<span :class="{'text-green-700': password.length > 7, 'text-red-700':password.length < 7 }"
class="font-medium text-sm ml-3"
x-text="password.length > 7 ? 'The minimum length is reached' : 'At least 8 characters required' "></span>
</li>
</ul>
</div>
<div>
<button type="submit" name="signup" value="Sign Up"
class=" transition ease-in-out group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
<span class="absolute left-0 inset-y-0 flex items-center pl-3">
<!-- Heroicon name: lock-closed -->
<svg class="h-5 w-5 text-indigo-500 group-hover:text-indigo-400"
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"
aria-hidden="true">
<path fill-rule="evenodd"
d="M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z"
clip-rule="evenodd" />
</svg>
</span>
Register
</button>
</div>
<div class="text-center text-sm text-grey-dark mt-4">
By signing up, you agree to the
<a class="no-underline border-b border-grey-dark text-grey-dark" href="#">
Terms of Service
</a> and
<a class="no-underline border-b border-grey-dark text-grey-dark" href="#">
Privacy Policy
</a>
</div>
</form>
<div class="text-grey-dark mt-6">
Already have an account?
<a class="no-underline border-b border-blue text-indigo-900" href="./login.php">
Log in
</a>.
</div>
</div>
</div>
<?php
if (isset($_POST['signup'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$password = sha1($_POST['password']);
$category = $_POST['category'];
$mobno = $_POST['phoneno'];
$rollno = $_POST['rollno'];
$type = 'Student';
$sql = "insert into user (Name,Type,Category,RollNo,EmailId,MobNo,Password) values ('$name','$type','$category','$rollno','$email','$mobno','$password')";
if ($conn->query($sql) === TRUE) {
echo "<script type='text/javascript'>alert('Registration Successful')</script>";
} else {
//echo "Error: " . $sql . "<br>" . $conn->error;
echo "<script type='text/javascript'>alert('User Exists')</script>";
}
}
?>
</body>
</html>