Created
November 4, 2018 14:11
-
-
Save pfieffer/d469878a1e725bbe55d40ade0b936fa0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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