<?php require_once '../php/Connection.php'; require_once '../php/LoginSystem.php'; $db = new Connection(); $loginSys = new LoginSystem($db); $loginSys->Logout(); ?> <!doctype html> <html> <head> <title>Logout</title> <meta charset="utf-8"/> <meta http-equiv="refresh" content="2; url=index.php" /> <link rel="stylesheet" type="text/css" href="css/php.css"/> </head> <body> <div><!-- wrapper div --> <div id="message"> You are now logged out! </div> </div><!-- wrapper div --> </body> </html>
<?php require_once '../php/Connection.php'; require_once '../php/LoginSystem.php'; $success = false; $error_msg = ''; try { if (!($db = new Connection())) { throw new Exception("Couldn't connect to database!"); } if (!($loginSys = new LoginSystem($db))) { throw new Exception("Couldn't connect to login system!"); } // Perform Logout if (!$loginSys->Logout()) { throw new Exception("Couldn't logout!"); } else { $success = true; } } catch (Exception $e) { $error_msg = $e->getMessage(); } echo json_encode(array('success' => $success, 'error_msg' => $error_msg));