-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidate.php
112 lines (86 loc) · 2.49 KB
/
validate.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
<?php
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
$unameErr = "";
echo "<br>";
if(empty($_POST['uname'])){
$unameErr = "Please Enter your name.";
$user_name = "";
} else {
$user_name = test_input($_POST['uname']);
}
if(empty($_POST['category'])){
$quiz_cate = "";
} else {
$quiz_cate = test_input($_POST['category']);
}
if($unameErr != null){
echo "<h5 style='color : #FFCC29 ; margin-top : 0'>";
print_r("$unameErr");
echo "</h5>";
} else{
header('Location: '. $quiz_cate .'.php');
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>User Details</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
form{
text-align : left;
margin-top : 10vh;
}
.input-fields{
color : #082032;
background-color : rgba(243, 233, 221,0.1);
border : 2px solid #F5F5F5;
margin-left : 1vw;
padding : 0.5rem 0.7rem;
border-radius : 15px;
font-size : 1.2rem;
text-align : center
}
button{
color : #F9ED69;
margin : 0 12vw;
padding : 1rem 10rem;
font-size : 1.5rem;
border : 3px solid #F9ED69;
border-radius : 55px;
margin-top : 5vh;
background-color : rgba(17, 153, 158,0.1);
}
button:hover{
color : #A2D5AB;
background-color : rgba(57, 174, 169,0.2);
border : 3px solid #A2D5AB;
}
</style>
</head>
<body>
<form method="post">
<label>Enter Your Name : </label>
<input class="input-fields" type="textbox" name="uname" autocomplete="off"><br>
<br>
<label>Select your preferred topic for quiz : </label>
<select name="category" class="input-fields">
<option value="mixed">Mixed</option>
<option value="gk">General Knowledge</option>
<option value="sci">Science</option>
<option value="comp">Computers</option>
</select>
<br><br><br>
<button type="submit">PLAY</button>
</form>
</body>
</html>