connect_errno) { echo "Failed to connect to MySQL: (" . $conn->connect_errno . ") " . $conn->connect_error; } else { debug("Successful Connection"); // debug($conn->host_info); } if($conn->select_db('ps2020')) { debug("Using ps2020"); } else { error($conn->error); } $msg = ''; if($_SERVER["REQUEST_METHOD"] == "POST") { $username = mysqli_real_escape_string($conn,$_POST["email"]); $password = hash('sha256', mysqli_real_escape_string($conn,$_POST["password"]), false); $result = $conn->query("SELECT * FROM user_account WHERE username = '$username' AND password = '$password'"); if($result) { if($result->num_rows == 1) { $row = $result->fetch_assoc(); // if($row['active'] == 1) // { // debug("Session started"); $_SESSION['username'] = $username; //the email is loaded to $_SESSION['email'] = $row['email']; //$_SESSION['accountType'] = $row['accountType']; $output['success'] = true; //$output['session'] = array("user" => $_SESSION['username'], "accountType" => $_SESSION['accountType']); //We need to check wether his/her account has become active or not $accountStatus = $row['active']; if($accountStatus == 0){ header("location: verifyEmail.php"); }else{ header('location:dashboard.php'); } exit; } else if($result->num_rows > 1) { //$output['success'] = false; $msg = "Duplicate Entries for login details"; } else { // $output['success'] = false; $msg = "Your Login Name or Password is invalid"; } } else { //$output['success'] = false; error($conn->connect_error); } //This is the case where we consider that user has tried to login via his/her email $result = $conn->query("SELECT * FROM user_account WHERE email = '$username' AND password = '$password'"); if($result->num_rows == 1) { $row = $result->fetch_assoc(); $_SESSION['email'] = $username; //the email is loaded to $_SESSION['username'] = $row['username']; //$_SESSION['accountType'] = $row['accountType']; $output['success'] = true; //$output['session'] = array("user" => $_SESSION['username'], "accountType" => $_SESSION['accountType']); //We need to check wether his/her account has become active or not $accountStatus = $row['active']; if($accountStatus == 0){ header("location: verifyEmail.php"); }else{ header('location: dashboard.php'); } exit; } else if($result->num_rows > 1) { //$output['success'] = false; $msg = "Duplicate Entries for login details"; } else { // $output['success'] = false; $msg = "Your Login Name or Password is invalid"; } }else { //$output['success'] = false; error($conn->connect_error); } //sendOutput(); $conn->close(); ?> Sign-In Page

Sign In

";
Forgot password?

Not a member? Register

Follow us at: