-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogramprocess.php
33 lines (29 loc) · 908 Bytes
/
programprocess.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
<?php include 'connect.php';?>
<?php session_start(); ?>
<?php
if(!isset($_SESSION['score'])){
$_SESSION['score'] = 0;
}
$query = "SELECT * FROM `pquestions`";
$result = mysqli_query($link,$query);
$total = $result->num_rows;
if($_POST){
$number = $_POST['number'];
$sel_choice = $_POST['choice'];
$next = $number+1;
$query = "SELECT * FROM `pchoices` WHERE question_ID = $number AND is_correct = 1";
$result = mysqli_query($link,$query);
$row = mysqli_fetch_assoc($result);
$correct_choice = $row['id'];
if($correct_choice == $sel_choice){
$_SESSION['score']++;
}
if($number == $total){
echo $number;
header("Location:programmingfinal.php");
}
else{
header("Location:basicprogrammingquestions.php?n=".$next);
}
}
?>