I think it is clear what i want this script to do. So it doesn't work. Any ideas?
<?php
//connect to the databse
include 'db.php';
$username = $_POST['username'];
$password = $_POST['password'];
//run query to match the user attempting to login with one from the database
$sql = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password'");
$login_check = mysql_num_rows($sql);
// check if the user info validates the db
if($login_check > 0){
while($row = mysql_fetch_array($sql)){
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}
// Register some session variables!
session_register('username');
$_SESSION['username'] = $username;
Header("Location: brothers.php");
}
} else {
echo "You could not be logged in! Either the username and password do not match or you have not validated your membership!<br />
Please try again!<br />";
include 'login.php';
?>