Implement Guestbook Display + Mobile Display

This commit is contained in:
Evan G. 2024-04-21 17:58:09 -05:00
parent 8da3310285
commit 38f9f9e6f2
Signed by: fbievan
GPG key ID: 55FAB8CB6842F080
6 changed files with 75 additions and 34 deletions

View file

@ -1,23 +1,31 @@
<?php
# Define Inital Variables
$fname = $_POST["fname"];
$fmsg = $_POST["fmessage"];
# Setup SaveMSG Array
$fname = htmlspecialchars($_POST["fname"]);
$fmsg = htmlspecialchars($_POST["fmessage"]);
$savemsg = array("name" => $fname, "message" => $fmsg);
# Show Array
echo json_encode($savemsg);
# Setup JSON
$data = json_decode(file_get_contents('test.json', true));
$data = json_decode(file_get_contents('test.json'), true);
# Add
array_unshift($data , $savemsg);
var_dump($data);
# Check name and message
if ($fname == "") {
echo "There is no name, Try again with a name";
exit();
}
if ($fmsg == "") {
echo "There is no message, Try again with a message";
exit();
}
file_put_contents('test.json', json_encode($data, JSON_PRETTY_PRINT));
echo $fmsg;