I'm fairly new to PHP and am working on creating a custom CMS. Right now, I have a table called "admin_users" with records of my admin users (first_name, last_name, username, password). When a user submits the login form, if the query that runs finds a username/password match in the db, I use the following code:
Code: Select all
session_start();
$_SESSION['valid'] = "yes";
$_SESSION['user'] = $_POST['username'];
header("Location: ../index.php");
Now I'm trying to create a "log out" link. Here's what I did on the first try:
Code: Select all
<a href="index.php?c=logout&task=1" title="Logout">Log Out</a>Code: Select all
if ($_GET[task] == 1 ) {
$_SESSION[valid] = "";
header('Location: skin/login.php');
exit;
}What is the proper way to handle a log out using a link? Any help with this would be greatly appreciated. I'm open to any and all criticism.