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

@ -4,14 +4,42 @@
<meta charset="UTF-8">
<title>My Cool Guestbook!</title>
<link rel="stylesheet" href="../readable.css"</link>
<link rel="stylesheet" href="./guestbook.css"</link>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
This is a guestbook, made by fbievan
<header>
<h1>Guestbook</h1>
<p>This is a guestbook, made by fbievan</p>
</header>
<nav>
<a href="../index.html">Back Home</a>
</nav>
<main>
<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>
</form>
<?php
$data = json_decode(file_get_contents('test.json'), true);
echo "<div>";
foreach($data as $post) {
echo '<section class="guestbookpost">';
echo "<h4>";
echo $post["name"] . "<br>";
echo "</h4>";
echo "<p>";
echo $post["message"] . "<br>";
echo "</p>";
echo "</section>";
}
echo "</div>";
?>
</main>
<footer>
I'm cool
</footer>
</body>
</html>

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;

View File

@ -1,24 +1,23 @@
.articles {
padding: 5px;
border: var(--line-width) solid;
border-top-style: dashed;
border-bottom-style: dashed;
border-right-style: none;
border-left-style: none;
}
section {
.articles {
padding: 5px;
border: var(--line-width) solid;
border-left-style: none;
border-top-style: dashed;
border-bottom-style: dashed;
border-right-style: none;
border-top-style: none;
text-align: left;
padding-bottom: 20px;
padding-top: 0px;
}
h3 {
text-align: left;
font-size: 1.4rem;
margin-top: 10px;
padding-top: 0px;
}
border-left-style: none;
}
section {
border: var(--line-width) solid;
border-left-style: none;
border-right-style: none;
border-top-style: none;
text-align: left;
padding-bottom: 20px;
padding-top: 0px;
}
h3 {
text-align: left;
margin-top: 10px;
padding-top: 0px;
}

View File

@ -3,8 +3,9 @@
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="readable.css">
<link rel="stylesheet" href="readable.css?v1.1.0">
<link rel="stylesheet" href="homepage.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<nav>
<a href="./index.html">Home</a>
@ -13,6 +14,8 @@
</nav>
<body>
<h1>Fbi's Epic Blog</h1>
</main>
<article>
<div class="articles">
<section>
<a href="./post1.html">
@ -33,5 +36,8 @@
This is amazing
</section>
</div>
<p>thank</p>
</article>
</main>
</body>
</html>

View File

@ -4,6 +4,7 @@
<meta charset="UTF-8">
<title>My First Post - Fbi's Epic Blog</title>
<link rel="stylesheet" href="readable.css"</link>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<nav>

View File

@ -284,4 +284,3 @@ form:not(.exclude) label:not(input:is([type="checkbox"], [type="radio"]) + label
font-weight: bold;
}