Skip to content

Commit 60734c1

Browse files
done
1 parent 2cabc6d commit 60734c1

2 files changed

Lines changed: 7 additions & 21 deletions

File tree

Unit-3/24-form-enquiry-json-file-storage.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@
3333
'phone' => $phone,
3434
'erp' => $erp
3535
];
36+
37+
// Simple Way To Display
38+
print_r($enquiryData);
39+
echo "<br>Name: ".$enquiryData['name'];
40+
41+
// Store In JSON File
3642
$file = __DIR__ . '/U03-enquiries-data.json';
37-
if (file_exists($file)) {
38-
$currentData = json_decode(file_get_contents($file), true);
39-
$currentData[] = $enquiryData;
40-
file_put_contents($file, json_encode($currentData, JSON_PRETTY_PRINT));
41-
} else {
42-
file_put_contents($file, json_encode([$enquiryData], JSON_PRETTY_PRINT));
43-
}
43+
file_put_contents($file, json_encode([$enquiryData], JSON_PRETTY_PRINT));
4444
echo "<p style='text-align: center; color: green;'>Enquiry submitted successfully!</p>";
4545
}
4646
?>

Unit-3/enquiries-data.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)