title: Logout button php
body: <p>I have this code and need the code to add a logout button, can anyone write out the code for a log out button that will log out the user, I read something about destroy session but do not know how to write the code out, thank you!</p>
  
  <pre><code>&lt;?php
      include 'connection.php';
      //start of checking if user is logged in code
      if (!valid_credentials) {
      header('Location: login.php');
      exit();
      }
  
  $_SESSION['user'] = 'username';
  
  
  if (!isset($_SESSION['user'])) {
      header('Location: login.php');
      exit();
  }
      //end of logged in code and starting a session
  
  $query = "SELECT * FROM people";
  $result = mysql_query($query);
  While($person = mysql_fetch_array($result)) {
      echo "&lt;h3&gt;" . $person['Name'] . "&lt;/h3&gt;";
      echo "&lt;p&gt;" . $person['Description'] . "&lt;/p&gt;";
      echo "&lt;a href=\"modify.php?id=" . $person['ID']. "\"&gt;Modify User&lt;/a&gt;";
      echo "&lt;span&gt; &lt;/span&gt;";
      echo "&lt;a href=\"delete.php?id=" . $person['ID']. "\"&gt;Delete User&lt;/a&gt;";
  }
  ?&gt;
  &lt;h1&gt;Create a User&lt;/h1&gt;
  &lt;form action="create.php" method="post"&gt;
      Name&lt;input type ="text" name="inputName" value="" /&gt;&lt;br /&gt;
      Description&lt;input type ="text" name="inputDesc" value="" /&gt;
      &lt;br /&gt;
      &lt;input type="submit" name="submit" /&gt;
  &lt;/form&gt;
  </code></pre>