title: simple login system spa/php/mysql/jquery
body: <p>I am trying to create a simple login system - I have gotten as far as my user being able to sign in and see his profile page. I am trying to make the link work in the login_success.php template...right now it just appends "#" to the url (because I am using that as a place holder.</p>
  
  <p>Here is my code:</p>
  
  <p>js/application.js</p>
  
  <pre><code>$(document).ready(function() {
      $("#main").load("templates/indexforms.php", function () {
          $("#login").submit(function(e) {
              e.preventDefault();
              $.post("checklogin.php", $(this).serialize(), function() {
                  $("#main").load("templates/login_success.php");
                  $("#login").remove();
                  $("#register").remove();
              });
          });
  
          $("#register").submit(function(e) {  
              e.preventDefault();
              $.post("checkreglogin.php", $(this).serialize(), function(){
                  $("#main").load("templates/login_success.php");
                  $("#login").remove();
                  $("#register").remove();
              });
          });
      });
  
  
      $("#loginlinkdiv a").click(function(event) {
          event.preventDefault();
          $("#main").empty();
          $("#main").load("templates/logout.php");
      });
  
      $("#logoutlinkdiv a").click(function(event) {
          event.preventDefault();
          $("#main").empty();
          $("#main").load("templates/indexforms.php");
      });
  });
  </code></pre>
  
  <p>templates/login_success.php</p>
  
  <pre><code>&lt;?php
  session_start();
  
  if($_SESSION['username'] === null){
      header("location: ../index.php");
  }
  ?&gt;
  
  &lt;h1&gt;Login Successful&lt;/h1&gt;
  &lt;h2&gt;Username: &lt;? echo $_SESSION['username']?&gt;&lt;/h2&gt;
  &lt;div id="logoutlinkdiv" &gt;
      &lt;a href = "#" &gt;Log out&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I can't figure out why nothing happens when I click the log out link.</p>