...

View Full Version : Creating a logout link for simple login script



Errica
04-27-2006, 07:03 PM
I'm using this simple php login script and I'd like to have a link that will let you log out. How is it done?



<?php

// Designate your username and password
$username = "user";
$password = "pass";

if ($_POST['user'] != $username || $_POST['pass'] != $password) {

?>

<h1>Login</h1>

<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<p><label for="user">Username:</label><br>
<input type="text" title="Please enter your Username" name="user"></p>

<p><label for="pass">Password:</label><br>
<input type="password" title="Please enter your Password" name="pass"></p>

<p><input type="submit" name="Submit" value="Login"></p>

</form>

<?php

}
else {

?>

<!-- Place your Password Protected content here -->

<p>Content.</p>

<?php

}

?>

Calilo
04-27-2006, 07:45 PM
Hi errica, as i see your script it seems you dont need a logout functions, logout functions are important or usefull when you are using cookies, since you destoy those cookies on the user computer and then he wont be able to get in without rewriting his password, but here in your script since you are not using cookies you cand just put a link pointing anywhere outside your script and if the user tries to get in again, he well be asked for his password again,

so just put a link to anyother page youve got, and that should make the trick

luck

Calilo



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum