title: how to replace login with logout when a user is logged in
body: <p>I am trying with a website where there is a login/register wizerd. I want that when a user is logged in the login and register link will be replace by a logout link.how can I do this?
  my codes are here...</p>
  
  <p>header.php</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  
  
  &lt;link rel="stylesheet" type="text/css" href="style.css"/&gt;
  
  &lt;/head&gt;
  
  &lt;body class="body"&gt;
  &lt;div id="inbody"&gt;
  
  &lt;div class="main_header"&gt;
      &lt;div class="site_name"&gt;
  
      &lt;/div&gt;
      &lt;div class="add"&gt;
          &lt;p&gt;&lt;a class="link" href="add.php" style="text-decoration:none"&gt;Adds&lt;/a&gt;&amp;nbsp &amp;nbsp
              &lt;a class="link" href="login.php" style="text-decoration:none"&gt;login&lt;/a&gt;&amp;nbsp &amp;nbsp
          &lt;a class="link" href="register.php" style="text-decoration:none"&gt;Register&lt;/a&gt;&lt;/p&gt;
  
  
  
      &lt;/div&gt;
  &lt;/div&gt;
  
  
  
          &lt;div class="main_body_part"&gt; 
  </code></pre>
  
  <p>home.php</p>
  
  <pre><code>&lt;?php
  include ("include/header.php");
  ?&gt; 
  </code></pre>
  
  <p>login_success.php</p>
  
  <pre><code>&lt;?php
  
  include 'database.php';
  session_start();
  $u_name=$_POST['u_name'];
  $password=$_POST['password'];
  
  login($u_name, $password);
  function login($name,$pass)
  {
      $sql = "SELECT * FROM registration WHERE user_name='$name'";
      $result = mysql_query($sql);
      while($row =  mysql_fetch_array($result))
  {
      if($row['password']==$pass)
      {
         $_SESSION['id']=$row['user_id'];
         header('Location:home.php');
      }
      else 
      {
          echo 'not log in';
      }
  }
  }
  
  
  
  ?&gt;
  </code></pre>
  
  <p>database.php</p>
  
  <pre><code>&lt;?php
  
  $con = mysql_connect("localhost", "root" ,"");
  if($con)
  {
  mysql_select_db("finalproject", $con);
  }
  </code></pre>
  
  <p>Now how can I do this????</p>