| @@ -2,7 +2,7 @@ | |||||
| <?php | <?php | ||||
| // the footer just adds a logout button at the bottom of every page for the currently logged in user | // the footer just adds a logout button at the bottom of every page for the currently logged in user | ||||
| if (isset($_SESSION['userid']) && ($_SESSION['username'])) { | if (isset($_SESSION['userid']) && ($_SESSION['username'])) { | ||||
| echo '<center><br /><br /><form method="post" action="logout.php"><input type="hidden" name="logout"><input type="submit" value="Logout"></form></center>'; | |||||
| echo '<center><br /><br /><form method="post" action="logout.php"><input type="hidden" name="action" value="logout" ><input type="submit" value="Logout"></form></center>'; | |||||
| } | } | ||||
| ?> | ?> | ||||
| </body> | </body> | ||||
| @@ -3,7 +3,9 @@ | |||||
| <HEAD> | <HEAD> | ||||
| <link rel="stylesheet" type="text/css" href="style.css"> | <link rel="stylesheet" type="text/css" href="style.css"> | ||||
| <?php | <?php | ||||
| session_start(); | |||||
| if (session_status() == PHP_SESSION_NONE) { | |||||
| session_start(); | |||||
| } | |||||
| $userid = (isset($_SESSION['userid']) ? $_SESSION['userid'] : null); | $userid = (isset($_SESSION['userid']) ? $_SESSION['userid'] : null); | ||||
| include_once ('connect.php'); | include_once ('connect.php'); | ||||
| $con = mysqli_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASS, DATABASE_NAME); | $con = mysqli_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASS, DATABASE_NAME); | ||||
| @@ -17,7 +19,13 @@ if (!$userid){ | |||||
| echo '<input type="submit" value="Login ..."></form><br /><br />'; | echo '<input type="submit" value="Login ..."></form><br /><br />'; | ||||
| echo 'If you haven\'t registered an account yet,<br />please click <a href="register.php" class="navlink">here</a> to create one.<br />'; | echo 'If you haven\'t registered an account yet,<br />please click <a href="register.php" class="navlink">here</a> to create one.<br />'; | ||||
| } else { | } else { | ||||
| echo '<title>' . $pagetitle . '</title></head><body><center>'; | |||||
| echo '<title>'; | |||||
| if (isset($pagetitle)) { | |||||
| echo $pagetitle; | |||||
| } else { | |||||
| echo 'GWST'; | |||||
| } | |||||
| echo '</title></head><body><center>'; | |||||
| echo '(<a href="index.php" class="navlink">Home</a>) (<a href="preferences.php" class="navlink">Options</a>) '; | echo '(<a href="index.php" class="navlink">Home</a>) (<a href="preferences.php" class="navlink">Options</a>) '; | ||||
| if ($_SESSION['admin'] == 1){ | if ($_SESSION['admin'] == 1){ | ||||
| echo'(<a href="adminlanding.php" class="navlink">Administration</a>) '; | echo'(<a href="adminlanding.php" class="navlink">Administration</a>) '; | ||||
| @@ -9,7 +9,9 @@ | |||||
| <?php | <?php | ||||
| include_once ('connect.php'); | include_once ('connect.php'); | ||||
| $con = mysqli_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASS, DATABASE_NAME); | $con = mysqli_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASS, DATABASE_NAME); | ||||
| session_start(); | |||||
| if (session_status() == PHP_SESSION_NONE) { | |||||
| session_start(); | |||||
| } | |||||
| $username = mysqli_real_escape_string($con, $_POST['username']); | $username = mysqli_real_escape_string($con, $_POST['username']); | ||||
| $password = $_POST['password']; | $password = $_POST['password']; | ||||
| @@ -1,17 +1,16 @@ | |||||
| <?php | <?php | ||||
| $pagetitle = "Logging Out"; | $pagetitle = "Logging Out"; | ||||
| include_once ('header.php'); | include_once ('header.php'); | ||||
| $logout = $_GET['action']; | |||||
| if (isset($_GET['action'])) { | |||||
| $logout = $_GET['action']; | |||||
| } else { | |||||
| $logout = $_POST['action']; | |||||
| } | |||||
| if ($logout == "logout"){ | if ($logout == "logout"){ | ||||
| session_unset(); | session_unset(); | ||||
| session_destroy(); | session_destroy(); | ||||
| header("refresh:2;url=index.php"); | header("refresh:2;url=index.php"); | ||||
| echo '<CENTER>You have been logged out ...<BR />Returning to login screen in a few seconds</CENTER>'; | echo '<CENTER>You have been logged out ...<BR />Returning to login screen in a few seconds</CENTER>'; | ||||
| } else if (isset($_POST['logout'])){ | |||||
| session_unset(); | |||||
| session_destroy(); | |||||
| header("refresh:2;url=index.php"); | |||||
| echo '<CENTER>You have been logged out ...<BR />Returning to login screen in a few seconds</CENTER>'; | |||||
| } else { | } else { | ||||
| echo '<CENTER>Something went wrong, you haven\'t been logged out!<BR /><BR />Please click <A HREF="logout.php" CLASS="navlink">HERE</A> to try again</CENTER>'; | echo '<CENTER>Something went wrong, you haven\'t been logged out!<BR /><BR />Please click <A HREF="logout.php" CLASS="navlink">HERE</A> to try again</CENTER>'; | ||||
| } | } | ||||