/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] stop login on fail

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>
[/code]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@kprocauthorApr 23.2006 — I figured it out,

just added exit(); after the message
×

Success!

Help @kproc spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...