diff --git a/guestbook/index.html b/guestbook/index.html index 38025ad..17ab7bd 100644 --- a/guestbook/index.html +++ b/guestbook/index.html @@ -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> diff --git a/guestbook/submit.php b/guestbook/submit.php index 9352661..2f72818 100644 --- a/guestbook/submit.php +++ b/guestbook/submit.php @@ -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; + diff --git a/homepage.css b/homepage.css index 9f21392..e2ceb7c 100644 --- a/homepage.css +++ b/homepage.css @@ -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; + } + diff --git a/index.html b/index.html index d70cd45..81138a4 100644 --- a/index.html +++ b/index.html @@ -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> diff --git a/post1.html b/post1.html index dc85602..7a4ae73 100644 --- a/post1.html +++ b/post1.html @@ -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> diff --git a/readable.css b/readable.css index 90ed52b..e1fbee1 100644 --- a/readable.css +++ b/readable.css @@ -284,4 +284,3 @@ form:not(.exclude) label:not(input:is([type="checkbox"], [type="radio"]) + label font-weight: bold; } -