title: Adding Function on Sign Out button by php
body: <p>I am creating a website where I want to sign in and sing out. So when I sign in I redirect to home.html, so in home.html I added a button by naming it "logout", I want to add function on it so whenever I will click on that button it will sign me out. As I know already, the code I have to use but don't know how put that code to logout button?
  I want to know how I can refer my this button name="logout" button to that specific code 
  session_destroy(); so when I m in home.html click on Sign out button it will destroy my current season and locate me back to index.php.<br>
  index.php
  <div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form class="form-horizontal" role="form" action="process.php" method="post"&gt;
    &lt;div class="form-group"&gt;
      &lt;label id="email" for="inputtext" class="col-sm-4 control-label"&gt;User name:&lt;/label&gt;
      &lt;div class="col-sm-4"&gt;
        &lt;input type="text" class="form-control" id="inputEmail" placeholder="User name" name="username"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="form-group"&gt;
      &lt;label id="pass" for="inputPassword" class="col-sm-4 control-label"&gt;Enter Password&lt;/label&gt;
      &lt;div class="col-sm-4"&gt;
        &lt;input type="password" class="form-control" id="inputPassword" placeholder="Password" name="pass"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    
    &lt;div class="form-group"&gt;
      &lt;div class="col-sm-offset-2 col-sm-10"&gt;
        &lt;button type="submit" class="btn btn-success"&gt;Sign me in!&lt;/button&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>process.php </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
       $action = $_GET['action']; 
       if ($action == 'logout') {
       unset($_SESSION['username']); 
       }
       
       
       
       $username = $_POST ['username'];
       $password = $_POST ['pass']; 
       
       //fixed values
       
       if($username=='syedhasan' AND $password=='Syed712207') {
       echo "You have successfully logged in"; 
        header('Location: home.html');   
       }
       
       else {
       echo "Credential is wrong";  
        
       }
        
       ?&gt;</code></pre>
  </div>
  </div>
  
  in home.html i have added this button </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;input href="logout.php" type="submit" class="signout btn btn-warning"" value="Sign Out" name="logout"&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>THen i created logout.php </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  session_start(); 
  unset($_SESSION); 
  session_destroy(); 
  header("Location: index.php"); 
  ?&gt;</code></pre>
  </div>
  </div>
  </p>