-
Notifications
You must be signed in to change notification settings - Fork 0
/
history.php
executable file
·38 lines (29 loc) · 1.01 KB
/
history.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
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
$code = $_POST['code'];
$uname = $_POST['username'];
$filename = uniqid();
$servername = "localhost";
$username = "DexterGCC";
$password = "dexterSQL@123";
$dbname = 'Userdata';
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO Submissions(ID, code, user) VALUES ('$filename','$code','$uname')";
$result = $conn->query($sql);
$sql = "SELECT * from Submissions where user='$uname' ORDER BY Time DESC LIMIT 3";
$result = $conn->query($sql);
$conn->close();
echo "<h3>History:</h3>";
echo '<table class="table"><thead class="black white-text"><tr><th scope="col">ID</th><th scope="col">Time</th></tr></thead><tbody>';
foreach($result as $row)
{
echo "<tr><th><a href='view.php?id=".$row['ID']."'>".$row['ID']."</a></th><th>".$row['Time']."</th></tr>";
}
echo "</tbody></table>";
?>