-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisplay.php
More file actions
47 lines (42 loc) · 1.64 KB
/
display.php
File metadata and controls
47 lines (42 loc) · 1.64 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Registration Details</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h2>Registration Successful!</h2>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Collect form data
$name = htmlspecialchars($_POST['fullname']);
$email = htmlspecialchars($_POST['email']);
$gender = htmlspecialchars($_POST['gender']);
$course = htmlspecialchars($_POST['course']);
$address = htmlspecialchars($_POST['address']);
// File name where data will be saved
$filename = "registrations.csv";
// If file doesn’t exist, create it with headers
if (!file_exists($filename)) {
$file = fopen($filename, "w");
fputcsv($file, ["Full Name", "Email", "Gender", "Course", "Address"]);
} else {
$file = fopen($filename, "a");
}
// Save data into CSV
fputcsv($file, [$name, $email, $gender, $course, $address]);
fclose($file);
// Display data
echo "<p><strong>Name:</strong> $name</p>";
echo "<p><strong>Email:</strong> $email</p>";
echo "<p><strong>Gender:</strong> $gender</p>";
echo "<p><strong>Course:</strong> $course</p>";
echo "<p><strong>Address:</strong> " . nl2br($address) . "</p>";
echo "<p style='color:green;'><strong>Data saved to registrations.csv successfully!</strong></p>";
}
?>
</div>
</body>
</html>