Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2005
    Posts
    252
    Thanks
    23
    Thanked 0 Times in 0 Posts

    Creating a logout link for simple login script

    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 Code:
    <?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 



    ?>

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Mex
    Posts
    122
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •