-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave_response.php
More file actions
28 lines (23 loc) · 795 Bytes
/
save_response.php
File metadata and controls
28 lines (23 loc) · 795 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
<?php
date_default_timezone_set('Asia/Dhaka');
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST["name"];
$mobile = $_POST["mobile"];
$email = $_POST["email"];
$service = $_POST["service"];
$subService = $_POST["subService"];
$formData = array(
"name" => $name,
"mobile" => $mobile,
"email" => $email,
"service" => $service,
"subService" => $subService,
"submittedAt" => date("Y-m-d H:i:s")
);
$filePath = "responses.json";
$existingData = file_exists($filePath) ? json_decode(file_get_contents($filePath), true) : [];
$existingData[] = $formData;
file_put_contents($filePath, json_encode($existingData, JSON_PRETTY_PRINT));
echo "Thank you, $name! Your response has been saved.";
}
?>