survey_seahorse

Software Engineering Project - Fall 2018
Log | Files | Refs | README

commit ed8a1d41d48ee3872dc50989c332383fce969f36
parent 1c935b8a3dbf09d3ed794ecb69e0b379ca235a74
Author: John Kubach <johnkubach@gmail.com>
Date:   Mon, 17 Dec 2018 14:54:16 -0500

home page message

admins can now set a banner message on the home page for all users to see

Diffstat:
Mwebsite/controlpanel.php | 10++++++++++
Awebsite/res/admin-message.php | 17+++++++++++++++++
2 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/website/controlpanel.php b/website/controlpanel.php @@ -1,5 +1,9 @@ <?php session_start(); + +ini_set('display_errors', 'On'); +error_reporting(E_ALL | E_STRICT); + include_once 'config.php'; if (!isset($_SESSION['admin'])) { header("Location: res/nope.php"); @@ -31,4 +35,10 @@ if (!isset($_SESSION['admin'])) { <button type='submit' name='admin' > Create New Admin Account</button> </form> +<form class="banner-message" action="res/admin-message.php" method="POST"> + <input type='text' name='message' placeholder='New Message'> <br> + <button type='submit' name='admin' > New Banner Message </button> + <button type='submit' name='remove' > Remove Current Banner Message </button> +</form> + <a href="index.php"> Home </a> <br> diff --git a/website/res/admin-message.php b/website/res/admin-message.php @@ -0,0 +1,17 @@ +<?php +ini_set('display_errors', 'On'); +error_reporting(E_ALL | E_STRICT); + +if (!empty($_POST['message'])) { + $message = $_POST['message']; + $var_str = var_export($message, true); + $var = "<?php\n\n\$message = $var_str;\n\n?>"; + file_put_contents("txt/msg.php",$var); + header("Location: ../controlpanel.php?msg=success"); +} elseif (isset($_POST['remove'])) { + file_put_contents("txt/msg.php",""); + header("Location: ../controlpanel.php?msg=success"); +} else { + header("Location: ../controlpanel.php?err=nomsg"); +} +