Skip to content

Instantly share code, notes, and snippets.

@pfieffer
Created November 4, 2018 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pfieffer/d469878a1e725bbe55d40ade0b936fa0 to your computer and use it in GitHub Desktop.
Save pfieffer/d469878a1e725bbe55d40ade0b936fa0 to your computer and use it in GitHub Desktop.
<?php
//For connecting the database-->
$link = mysqli_connect("localhost","root","", "practise");
if (!$link) {
die("Connection failed: " . mysql_error());
}else{
mysqli_select_db ($link, 'practise') or die ("Could not select database.");
}
//Start session
session_start();
//Check whether the session variable username is present or not
if (!isset($_SESSION['username']) || ($_SESSION['username'] == '')) {
echo "Could not logout";
} else{
//close the database connection
mysqli_close($link);
session_destroy();
header("location: index.php");
exit();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment