-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubmitRecord.php
More file actions
38 lines (32 loc) · 901 Bytes
/
Copy pathsubmitRecord.php
File metadata and controls
38 lines (32 loc) · 901 Bytes
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
<?php
session_start();
// setup
$host = "localhost";
$username = "root";
$password = "";
$dbname = "spekmadb";
// connect to db
$conn = new mysqli($host, $username, $password, $dbname);
// check if connection is errorless
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// send sql query
$score = (int)$_REQUEST["sc"] * 25;
$gred = "";
if ($score == 100) {
$gred = "A";
} elseif ($score >= 75) {
$gred = "B";
} elseif ($score >= 50) {
$gred = "C";
} else {
$gred = "D";
}
$idpeng = $_REQUEST["ip"];
$idsoalan = $_REQUEST["is"];
$query = "UPDATE perekodan SET markah = $score, gred = '$gred'
WHERE perekodan.idpeng = '$idpeng' AND perekodan.idsoalan = $idsoalan";
$result = mysqli_query($conn, $query);
echo $result;
?>