php - Log out when click on link -


i'm having trouble log in code website, system allows user log in , log out when user logged in , clicks on webpage link, signs them out. want them stay logged in on pages until user clicks log out themselves.

the loginform.php:

    <div id="contact">        <form id="form" action="<?php $_server['php_self'];?>" method="post">            username: <input type="text" name="liusername" id="liusername">            password: <input type="password" name="lipassword" id="lipassword">            <input type='submit' value='login'   name="lisubmit">        </form>     </div> 

php code on heading.php:

    <?php  if ($_session['loggedin'] === true){  echo "you have signed in - <a href='loggedout.php'>click here log out</a>";   } else { include 'loginform.php';  }   if (isset($_post['lisubmit'])){  $query = "select user_id, user_password, user_username users         user_username = '".$_post['liusername']."'";         $result = mysql_query($query) or die (mysql_error());         $row = mysql_fetch_array($result);          if ($row['user_password'] === $_post['lipassword'] && $row['user_username'] === $_post['liusername']){              $_session['loggedin'] = true;             $_session['id'] = $row['user_id'];         }else{             $_session['loggedin'] = false;             $_session['id'] = 0;             include 'loginform.php';          } }     ?> 

index.php:

    if(empty($_session['loggedin'])){$_session['loggedin'] = false;     } 

loggedout.php:

    <?php       session_start();      $_session= array();      session_destroy();      header('location: index.php');      ?> 


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -