function database_user_login($username, $password) { global $mysqli; $username = sanitize_input($username); $password = sanitize_input($password); $userID = database_get_userID($username); $q = "SELECT password FROM users WHERE userID='{$userID}'"; $result = mysqli_query($mysqli, $q); $row = mysqli_fetch_array($result); $datapass = $row['password']; // If the database password and the passed in password are the same // the user is verified. Otherwise, return 0. if (validate_password($password, $datapass)) { set_user_logged_in($userID); } else { set_user_logged_out(); $userID = 0; } return $userID; }
<?php include "database_queries.php"; if (!empty($_GET["logout"])) { set_user_logged_out(); $userID = 0; } else { $userID = get_user_logged_in(); } ?> <!-- This is the start of the MySocial HTML code for every page--> <html> <head> <link href='http://fonts.googleapis.com/css?family=Just+Another+Hand' rel='stylesheet' type='text/css'> <link rel="stylesheet" type="text/css" href="style.css" /> <title>Welcome to Connect+</title> </head> <body> <div id = "topcontainer"> <div id = "header" style="padding-top:2%"> <a href = "index.php">Connect+</a> <!-- NOTE: here you can modify the header text of this website. Perhaps, add an image --> <div id = "navigation"> <?php