Browse Source

got rid of undefined variables clogging up the web server log file

pull/16/head
mauirixxx 7 years ago
parent
commit
7db29117da
4 changed files with 19 additions and 10 deletions
  1. +1
    -1
      footer.php
  2. +10
    -2
      header.php
  3. +3
    -1
      login.php
  4. +5
    -6
      logout.php

+ 1
- 1
footer.php View File

@@ -2,7 +2,7 @@
<?php
// 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'])) {
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>

+ 10
- 2
header.php View File

@@ -3,7 +3,9 @@
<HEAD>
<link rel="stylesheet" type="text/css" href="style.css">
<?php
session_start();
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
$userid = (isset($_SESSION['userid']) ? $_SESSION['userid'] : null);
include_once ('connect.php');
$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 'If you haven\'t registered an account yet,<br />please click <a href="register.php" class="navlink">here</a> to create one.<br />';
} 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>) ';
if ($_SESSION['admin'] == 1){
echo'(<a href="adminlanding.php" class="navlink">Administration</a>) ';


+ 3
- 1
login.php View File

@@ -9,7 +9,9 @@
<?php
include_once ('connect.php');
$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']);
$password = $_POST['password'];



+ 5
- 6
logout.php View File

@@ -1,17 +1,16 @@
<?php
$pagetitle = "Logging Out";
include_once ('header.php');
$logout = $_GET['action'];
if (isset($_GET['action'])) {
$logout = $_GET['action'];
} else {
$logout = $_POST['action'];
}
if ($logout == "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 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 {
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>';
}

Loading…
Cancel
Save