So I have an admin login page set up where after the admin puts their username and password in and hits the login button it either A. tells them their username or password is incorrect if the username and password doesn’t match the database information or B. redirects them to the index.php page if the username and password are correct. A works its getting B to work is the problem. The code is as follows:
<?php
if (isset($_POST[‘submit’])) {
$username = $_POST[‘username’];
$password = $_POST[‘password’];
$sql = “SELECT * FROM Admin WHERE username = ‘”.$username.”‘ AND password = ‘”.$password.”‘”;
$r = mysql_query($sql);
if (!$r) {
echo ‘<p>Username or Password is incorrect</p>’;
} else {
header(“Location: index.php”);
}
}
?>
<center>
<img src=”assets/LOGO.JPG” width=”244″ height=”61″ alt=”RealtyNET Service Realtors” />
<h3>Administrator Login</h3>
<form method=”post” action=”admin.php” name=”adminLogIn”>
<label>Username:</label>
<input size=”15″ name=”username” type=”text” />
<br />
<br />
<label>Password:</label>
<input size=”15″ name=”password” type=”password” />
<br />
<br />
<input type=”submit” name=”submit” value=”Log In” style=”cursor: pointer;” />
</form>
if i comment out the header() and replace it with a simple echo statement i can see the echo, but when I do the header() function it stays at the admin.php page and empties the text fields.