-
Notifications
You must be signed in to change notification settings - Fork 1
/
scribe.html
221 lines (181 loc) · 5.12 KB
/
scribe.html
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<?php
require "db.php";
if(isset($_POST['uname'])&&isset($_POST['pwd'])&&isset($_POST['email'])&&isset($_POST['phno'])&&isset($_POST['gender']))
{
$name=$_POST['uname'];
$password=$_POST['pwd'];
$email=$_POST['email'];
$phone=$_POST['phno'];
$gender=$_POST['gender'];
if(!empty($_POST['username'])&&!empty($_POST['password'])&&!empty($_POST['email'])&&!empty($_POST['phone'])&&!empty($_POST['gender']))
{
$query="select email from stureg where email='$email'";
$query_run=mysqli_query($sql2,$query);
if(mysqli_num_rows($query_run)==1)
{
?>
<script>
alert('<?php echo 'user already exists';?>');
</script>
<?php
}
else
{
$query1="insert into stureg values('".mysqli_real_escape_string($sql2,$username)."','".mysqli_real_escape_string($sql2,$password)."','".mysqli_real_escape_string($sql2,$email)."','".mysqli_real_escape_string($sql2,$phone)."','".mysqli_real_escape_string($sql2,$gender)."')";
mysqli_query($sql2,$query1);
if(!$query1)
{
?>
<script>
alert('<?php echo 'Could not register. Try again later';?>');
</script>
<?php
}
else
{
?>
<script>
alert('<?php echo "success";?>');
//window.location="login.php";
</script>
<?php
//header("Location:login.php");
}
}
}
}
else{
echo "enter all fields";
}
}
?>
?>
<html><!DOCTYPE html>
<html>
<style>
input[type=text], select {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
input[type=password], select {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
input[type=submit] {
width: 100%;
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
}
input[type=submit]:hover {
background-color: #45a049;
}
div {
border-radius: 5px;
background-color: #f2f2f2;
padding: 20px;
}
body {
background-image: url('ieye.png');
background-repeat: no-repeat;
background-attachment: fixed;
}
</style>
<body>
<h2 style="margin-left:250px;color:green;">Sign Up</h2>
<div style="width:50%;margin-left:250px">
<form action="/action_page.php">
<label>Type:</label>
<span style="color:red">*</span>
<select id="type" name="type">
<option value="admin">Admin</option>
<option value="student">Student</option>
<option value="scribe">Scribe</option>
</select>
<label >Name:</label>
<span style="color:red">*</span>
<input type="text" id="uname" name="uname" placeholder="Enter name" required><br>
<label >Password:</label>
<span style="color:red">*</span>
<input type="password" id="pwd" name="pwd" placeholder="Enter password">
<label >Contact:</label>
<input type="text" id="phno" name="phno" placeholder="Enter phone number" required>
<label >Email:</label>
<span style="color:red">*</span>
<input type="text" id="email" name="email" placeholder="Enter mail id">
<label >Gender:</label>
<span style="color:red">*</span><br>
<input type="radio" name="gender" value="male" checked> Male<br>
<input type="radio" name="gender" value="female"> Female<br>
<input type="radio" name="gender" value="other"> Other
<input type="submit" value="Submit">
</form>
</div>
<?php
$nameErr = $emailErr = $genderErr = $websiteErr = "";
$name = $email = $gender = $comment = $website = "";
if (isset($_POST["submit"])) {
if ($_POST["type"]=="Scribe") {
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name"])) {
$nameErr = "Name is required";
} else {
$name = test_input($_POST["uname"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
$nameErr = "Only letters and white space allowed";
}
}
if (empty($_POST["pwd"])) {
$nameErr = "Password is required";
} else {
$name = test_input($_POST["pwd"]);
// check if name only contains letters and whitespace
}
if (empty($_POST["phno"])) {
$nameErr = "Name is required";
} else {
$name = test_input($_POST["phno"]);
// check if name only contains letters and whitespace
}
if (empty($_POST["email"])) {
$emailErr = "Email is required";
} else {
$email = test_input($_POST["email"]);
// check if e-mail address is well-formed
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Invalid email format";
}
}
if (empty($_POST["gender"])) {
$genderErr = "Gender is required";
} else {
$gender = test_input($_POST["gender"]);
}
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
}
?>
</body>
</html>
</html>