Replaced 'break' with 'exit' and inserted 'isset' on cookie-check

This commit is contained in:
2014-05-22 08:41:34 +02:00
parent 9e77a137c3
commit be4b0a33ac

View File

@@ -1,10 +1,13 @@
<?php
# Check if the user is logged in and authenticated
if ( $_COOKIE['session'] ) { // If yes, continue loading page as normal
if (isset( $_COOKIE['session'] ))
{
# If yes, continue loading page as normal
# If not logged in, check if this is an attempt to login...
} else if ($_POST['do'] == "authenticate") {
}
else if (isset($_POST['do']) == "authenticate")
{
# If we're trying to login...
@@ -15,23 +18,28 @@ if ( $_COOKIE['session'] ) { // If yes, continue loading page as normal
# echo "Results: " . mysql_num_rows($result); // Debugging line
if (mysql_num_rows($result) === 1) { // If user found and password matches
if (mysql_num_rows($result) === 1)
{ // If user found and password matches
unset($_POST['do']); // No longer authenticating
# Create cookie and set it
$_COOKIE['session'] = '1';
setcookie('session',$_COOKIE['session']);
} else { // If user not found or password doesn't match
}
else
{ // If user not found or password doesn't match
unset($_POST['do']);
# Attempt login again. This should be limited in the future.
echo "Login failed. Please try again.";
include("login_form.inc");
break;
exit;
}
} else { // If this is the first visit to the user/admin area...
}
else
{ // If this is the first visit to the user/admin area...
echo "Please login:";
include "login_form.inc";
break;
exit;
}
?>