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.
Here is my code:
js/application.js
$(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");
});
});
templates/login_success.php
<?php
session_start();
if($_SESSION['username'] === null){
header("location: ../index.php");
}
?>
<h1>Login Successful</h1>
<h2>Username: <? echo $_SESSION['username']?></h2>
<div id="logoutlinkdiv" >
<a href = "#" >Log out</a>
</div>
I can't figure out why nothing happens when I click the log out link.