Created
November 10, 2018 09:00
-
-
Save pfieffer/4923691a68e5256fd54ac67c51790b63 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