<?php
//check for required fields from the form
if ((!$_POST['username']) || (!$_POST['password'])) {
header("Location: auth1.php"); //header("Location: auth1.php");
exit;
//set authorization cookie
$servername = "localhost";
$username = "tmc_user50";
$password = "Atl_344";
// Create connection
$conn = mysqli_connect($servername, $username, $password);
$message="";
if(count($_POST)>0) {
$conn = mysqli_connect("localhost","tmc_user50","Atl_344");
$result = mysqli_query($conn,"SELECT * FROM admin2 WHERE username='" . $_POST["username"] . "' and password = '". $_POST["password"]."'");
$count = mysqli_num_rows($result);
if($count==0) {
$message = "Invalid Username or Password!";
} else {
$message = "You are successfully authenticated!";
}
}
}
?>
When I enter any username ad password the code from auth2.php (the code above allows a connection anyway) I am attempting to redirect users back to auth1 if there is an incorrect username or password