-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubmit.php
More file actions
61 lines (52 loc) · 1.82 KB
/
submit.php
File metadata and controls
61 lines (52 loc) · 1.82 KB
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
<?php
session_start();
include 'db_connect.php';
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit();
}
$problem_id = $_GET['problem_id'] ?? null;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$status = $_POST['status'];
$time_taken = $_POST['time_taken'];
$date_solved = date('Y-m-d');
$notes = $_POST['notes'];
$user_id = $_SESSION['user_id'];
$stmt = $conn->prepare("INSERT INTO submissions (user_id, problem_id, status, time_taken, date_solved, notes) VALUES (?, ?, ?, ?, ?, ?)");
$stmt->bind_param("iissss", $user_id, $problem_id, $status, $time_taken, $date_solved, $notes);
$stmt->execute();
header("Location: problems.php");
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Submit Solution</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
</head>
<body class="bg-light">
<div class="container mt-5">
<h3>Submit Solution</h3>
<form method="post">
<div class="mb-3">
<label>Status:</label>
<select name="status" class="form-select" required>
<option value="solved">Solved</option>
<option value="unsolved">Unsolved</option>
</select>
</div>
<div class="mb-3">
<label>Time Taken (in minutes):</label>
<input type="number" name="time_taken" class="form-control" required>
</div>
<div class="mb-3">
<label>Notes (optional):</label>
<textarea name="notes" class="form-control" rows="4"></textarea>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
<a href="problems.php" class="btn btn-secondary">Cancel</a>
</form>
</div>
</body>
</html>