Implement Guestbook Display + Mobile Display
This commit is contained in:
parent
8da3310285
commit
38f9f9e6f2
6 changed files with 75 additions and 34 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue