Functioning Guestbook
This commit is contained in:
parent
3753b2977f
commit
8da3310285
|
@ -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>
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue