Functioning Guestbook

This commit is contained in:
Evan G. 2024-04-20 12:45:21 -05:00
parent 3753b2977f
commit 8da3310285
Signed by: fbievan
GPG Key ID: 55FAB8CB6842F080
2 changed files with 23 additions and 2 deletions

View File

@ -7,7 +7,7 @@
</head>
<body>
This is a guestbook, made by fbievan
<form action="./sumbit.php" method="post">
<form action="./submit.php" method="post">
<input type="text" name="fname" placeholder="name"></input>
<input type="text" name="fmessage" placeholder="Message"></input>
<input type="submit"></input>

View File

@ -1,2 +1,23 @@
<?php
echo "Hello World";
# Define Inital Variables
$fname = $_POST["fname"];
$fmsg = $_POST["fmessage"];
# Setup SaveMSG Array
$savemsg = array("name" => $fname, "message" => $fmsg);
# Show Array
echo json_encode($savemsg);
# Setup JSON
$data = json_decode(file_get_contents('test.json', true));
# Add
array_unshift($data , $savemsg);
var_dump($data);
file_put_contents('test.json', json_encode($data, JSON_PRETTY_PRINT));