Hi guys,
I'm messing about with PHP scripts and have a log in which queries the users in a database. If the user has a 1 in the table, they are admin and are directed to admin.php. If the user is the default (0) then they are directed to the normal page. But, what I can't seem to achieve is a redirect to an "opps" page if any of the above enter their details incorrectly.
What do I need to add?
I'm messing about with PHP scripts and have a log in which queries the users in a database. If the user has a 1 in the table, they are admin and are directed to admin.php. If the user is the default (0) then they are directed to the normal page. But, what I can't seem to achieve is a redirect to an "opps" page if any of the above enter their details incorrectly.
Code:
<?php
session_start();
include("connect.php");
function clean($value) {
if(get_magic_quotes_gpc()) $value = stripslashes($value);
return trim(mysql_real_escape_string($value));
}
if($_POST['login'] && $_POST['username'] && $_POST['password']) {
$username = clean($_POST['username']);
$password = md5($_POST['password']);
$result = mysql_query("SELECT username FROM users WHERE username = '$username' AND password = '$password'
And admin = '1'");
if(mysql_num_rows($result) > 0) {
$_SESSION['username'] = $username;
header("Location: correct.php");
}
else{
header("Location: wrong.php");
}
}
?>
What do I need to add?