Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ob_start();
- session_start();
- error_reporting(E_ALL ^ E_DEPRECATED); // debugging.
- include 'webinc/099111110102105103/100097116097098097115101/connect.php';
- require '115101099117114105116121/security.php';
- //require '102117110099116105111110115/functions.php';
- function getrow($q)
- {
- global $db;
- $checkquery = $db->query($q);
- if($checkquery === FALSE) {
- die($db->error()); //Error handling better.
- }
- $result = $db->fetch_array($checkquery);
- return $result;
- }
- function redirect_not_logged()
- {
- global $db;
- $username = $db->real_escape_string(trim($_SESSION['username']));
- $password = $db->real_escape_string(trim($_SESSION['password']));
- $check = getrow("SELECT * FROM accounts WHERE accountName='$username' && accountPassword='$password'");
- $id = $check['accountID'];
- $query = $db->query("SELECT * FROM `accounts` WHERE accountID = $id");
- while($row = $db->fetch_array($query))
- {
- $online = $row['accountStatus'];
- }
- if($online == 0)
- {
- echo " Not Logged In ";
- }
- }
- $logged_in = 0;
- if(isset($_SESSION['username']) && isset($_SESSION['password'])){
- $username = $db->real_escape_string(trim($_SESSION['username']));
- $username = $db->real_escape_string(trim($_SESSION['password']));
- $check = getrow("SELECT * FROM accounts WHERE accountName='$username' && accountPassword='$password'");
- if(isset($check['accountID'])){
- $logged_in = 1;
- if(isset($_GET['logout'])){
- unset($_SESSION['username']);
- unset($_SESSION['password']);
- $db->query("UPDATE accounts SET accountStatus=0 WHERE accountName='$username'");
- $db->query("UPDATE accounts SET accountLastLogin=now() WHERE accountName='$username'"); //Update LastOnline
- header('location: index.php');
- }
- }
- }
- ob_end_flush();
- ?>
- //// CONNECT
- $db = new mysqli('127.0.0.1', 'root', '', 'ltsgolearn');
- // echo $db->connect_errno; -> debugging.
- if($db->connect_errno){
- //echo $db->connect_error; -> debugging.
- die('Sorry, we are haveing some problems.');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement