Hi Below is code that I’m using check if user login & Password is valued.
If incorrect user name or password is entered the message below displays but so does the links.
How do I get it to end the code if user or password is invalued and just display the login page
[code=php]
// Convert password to md5 hash
$password = md5($password);
//check if the user info validates the db
$sql = mysql_query(“SELECT * FROM users WHERE username=’$username’ AND password=’$password’ AND activated=’1′”);
$login_check = mysql_num_rows($sql);
if($login_check > 0){
while($row = mysql_fetch_array($sql)){
foreach( $row AS $key => $val ){
$key = stripslashes( $val );
}
// Register some session variables!
$_SESSION[‘first_name’] = $first_name;
$_SESSION[‘last_name’] = $last_name;
$_SESSION[’email_address’] = $email_address;
$_SESSION[‘user_level’] = $user_level;
$_SESSION[‘username’] = $username;
mysql_query(“UPDATE users SET last_login=now() WHERE userid=’$userid'”);
header(“Location: login_success.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 ‘form_user_login.php’;
}
?>
<p><a href=”user_logout.php”>logout</a></p>
<p><a href=”all_database_enteries.php”>My Iformation</a></p>
<p><a href=”myinfo.php”>Get My Info</a></p>
<p><a href=”form_UpdateMyInformation.php”>Update My Information</a></p>
</body>