
login,php
By: a guest on
Aug 8th, 2012 | syntax:
None | size: 1.40 KB | hits: 15 | expires: Never
<?php
//Check to see if they accessed the page correctly
if (!isset($_POST['login_submit'])) {
$_SESSION['noaccess'] = "it is a restricted page.";
header("Location: ../index.php");
exit();
}
//Check to see if they're already logged in and exit if so
if (isset($_SESSION['loggedIn'])) {
$_SESSION['noaccess'] = "you are already logged in!";
header("Location: ../index.php");
exit();
}
//Check to see if they filled in the login form
if (!isset($_POST['login_user_email']) or $_POST['login_user_email']=="" or $_POST['login_pwd']=="" or !isset($_POST['login_pwd'])) {
$_SESSION['loginfail'] = "Please fill in all forms before submitting.";
header("Location: ../index.php");
exit();
}
//Connect to database
include '../includes/connect.php.inc';
//Set the form posts as variables
$emailaddress = mysql_real_escape_string($_POST['login_user_email']);
$pwd = mysql_real_escape_string($_POST['login_pwd']);
$query = "SELECT memberID,firstName,lastName,userPermission FROM members WHERE email='$emailaddress'";
$result = mysqli_query($cxn,$query) or die ("Couldn't execute query!");
$nrows = mysqli_num_rows($result);
//Checks to see if email is registered
if ($nrows!=1) {
$_SESSION['loginfail'] = "Your email address was not found in the database! Ensure you entered <b>the correct information</b> and that you have <b>already registered</b>.";
header("Location: ../index.php");
exit();
}