-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathtakeexam2.php
227 lines (172 loc) · 5.32 KB
/
takeexam2.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
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
222
223
224
225
226
227
<?php
session_start();
if ( $_SESSION[ "sidx" ] == "" || $_SESSION[ "sidx" ] == NULL ) {
header( 'Location:studentlogin' );
}
$userid = $_SESSION[ "sidx" ];
$userfname = $_SESSION[ "fname" ];
$userlname = $_SESSION[ "lname" ];
?>
<?php include('studenthead.php'); ?>
<div class="container">
<div class="row">
<div class="col-md-12">
<h3> Welcome <a href="welcomestudent"><?php echo "<span style='color:red'>".$userfname." ".$userlname."</span>";?></a></h3>
<?php
$varid = $_GET[ 'id' ];
include( 'database.php' );
$sql = "select * from studenttable where Eid='$userid'";
$sql2 = "select * from exam where Eid='$userid'";
$result = mysqli_query( $connect, $sql );
while ( $row = mysqli_fetch_array( $result ) ) {
?>
<!--exam question with student detalis-->
<fieldset>
<legend>Exam Details</legend>
<form action="" method="POST" name="update">
<div class="col-md-4">
<table>
<tr>
<td><strong>Enrolment number :</strong>
</td>
<td>
<?php $eno=$row['Eno'];
echo $eno; ?>
</td>
</tr>
<tr>
<td><strong>Name :</strong>
</td>
<td>
<?php $name=$row['FName']." ".$row['LName'];
echo $name; ?>
</td>
</tr>
</table>
</div>
<div class="col-md-4">
<table>
<tr>
<td><strong>Course :</strong>
</td>
<td>
<?PHP $cc=$row['Course'];
echo $cc; ?>
</td>
</tr>
<tr>
<td><strong>Applied For :</strong>
</td>
<td>
<?PHP echo $varid;?><br>
</td>
</tr>
</table>
</div>
<br>
<br>
<hr>
<div class="col-md-12">
<span style="color: red;"><h3>You can test your PHP skills with PHP Exam </h3></span>
<br>
<div>
<h4> <strong>Q1. What does PHP stand for?</strong></h4>
<label class="radio-inline">
<input type="radio" name="q1" value="o1" checked> Private Home Page
</label>
<label class="radio-inline">
<input type="radio" name="q1" value="o2" > Personal Hypertext Processor
</label>
<label class="radio-inline">
<input type="radio" name="q1" value="o3" > PHP: Hypertext Preprocessor
</label>
</div>
<br>
<br>
<div>
<h4> <strong>Q2. How do you write "Hello World" in PHP</strong></h4>
<label class="radio-inline">
<input type="radio" name="q2" value="o1" checked > Document.Write("Hello World");
</label>
<label class="radio-inline">
<input type="radio" name="q2" value="o2" > echo "Hello World";
</label>
<label class="radio-inline">
<input type="radio" name="q2" value="o3" > "Hello World";
</label>
</div>
<br>
<br>
<div>
<h4> <strong>Q3. All variables in PHP start with which symbol?</strong></h4>
<label class="radio-inline">
<input type="radio" name="q3" value="o1" checked> !
</label>
<label class="radio-inline">
<input type="radio" name="q3" value="o2" > &
</label>
<label class="radio-inline">
<input type="radio" name="q3" value="o3" > $
</label>
</div>
<br>
<br>
<div>
<h4> <strong>Q4. What is the correct way to end a PHP statement?</strong></h4>
<label class="radio-inline">
<input type="radio" name="q4" value="o1" checked > .
</label>
<label class="radio-inline">
<input type="radio" name="q4" value="o2" > New line
<label class="radio-inline">
<input type="radio" name="q4" value="o3" > ;
</label>
</div>
<br>
<br>
<div>
<h4> <strong>Q5. The PHP syntax is most similar to:</strong></h4>
<label class="radio-inline">
<input type="radio" name="q5" value="o1" checked> Perl and C
</label>
<label class="radio-inline">
<input type="radio" name="q5" value="o2" > VBScript
<label class="radio-inline">
<input type="radio" name="q5" value="o3" > JavaScript
</label>
</div>
<br><br>
<button type="submit" name="done" class="btn btn-primary">I am Done!</button>
</div>
</form>
</fieldset>
<?php
}
if ( isset( $_POST[ 'done' ] ) ) {
$tempeid = $userid;
$tempname = $name;
$tempeno = $eno;
$tempcourse = $cc;
$tempq1 = $_POST[ 'q1' ];
$tempq2 = $_POST[ 'q2' ];
$tempq3 = $_POST[ 'q3' ];
$tempq4 = $_POST[ 'q4' ];
$tempq5 = $_POST[ 'q5' ];
$sql = "INSERT INTO `exam`(Eno, Eid, Course, ExamName, Q1, Q2, Q3, Q4, Q5) VALUES ($tempeno,'$tempeid','$tempcourse','$varid','$tempq1','$tempq2','$tempq3','$tempq4','$tempq5')";
if ( mysqli_query( $connect, $sql ) ) {
echo "<br>
<br><br>
<div class='alert alert-success fade in'>
<a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a>
<strong>Success!</strong> Exam Have Submited.
</div>";
} else {
//error message if SQL query fails
echo "<br><Strong>Exam Submitting Faliure. Try Again</strong><br> Error Details: " . $sql . "<br>" . mysqli_error( $connect );
} //close the connection
mysqli_close( $connect );
}
?>
</div>
</div>
<?php include('allfoot.php'); ?>