-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset_date.php
73 lines (66 loc) · 2.58 KB
/
set_date.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
<?php
require_once('../auth.php');
// Replace 'your-database-name.sqlite' with the actual path to your SQLite database file
$database = new SQLite3('../database.sqlite');
// Get the current born of the user from the database
$query = "SELECT born FROM users WHERE email = :email";
$statement = $database->prepare($query);
$statement->bindValue(':email', $_SESSION['email']);
$result = $statement->execute();
$row = $result->fetchArray(SQLITE3_ASSOC);
$currentborn = $row['born'];
// Process the form submission if the user has selected a new born
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Get the selected born from the form
$selectedborn = $_POST['born'];
// Update the user's born in the database
$query = "UPDATE users SET born = :born WHERE email = :email";
$statement = $database->prepare($query);
$statement->bindValue(':born', $selectedborn);
$statement->bindValue(':email', $_SESSION['email']);
$statement->execute();
// Redirect the user to a success page or any other desired location
header("Location: set_date.php");
exit;
}
// Close the database connection
$database->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ArtCODE</title>
<link rel="manifest" href="manifest.json">
<link rel="icon" type="image/png" href="../icon/favicon.png">
<?php include('bootstrapcss.php'); ?>
</head>
<body>
<div class="container mb-5 mt-4">
<h3 class="fw-bold mb-3">
Set Your Date
</h3>
<div class="card border-0 bg-body-tertiary rounded-4 shadow-sm p-4 mb-4">
<h5 class="fw-bold">
<i class="bi bi-calendar-fill"></i> Set Date of Birth
</h5>
<p class="text-muted mb-4">Choose a new date to update your date of birth.</p>
<form method="POST" action="">
<div class="input-group">
<input type="date" class="form-control fw-bold" name="born" placeholder="Select a date" value="<?php echo $currentborn; ?>" required>
<span class="input-group-text"><i class="bi bi-calendar"></i></span>
</div>
<button type="submit" class="btn btn-primary w-100 fw-bold mt-2">Save</button>
</form>
</div>
<div class="d-flex">
<div class="ms-auto btn-group gap-2 mt-2">
<a href="../index.php" class="btn border-0 text-danger rounded fw-medium">Skip</a>
<a href="set_page.php" class="btn border-0 text-dark rounded fw-medium">Next</a>
</div>
</div>
</div>
<?php include('bootstrapjs.php'); ?>
</body>
</html>