Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Session {
- function __construct() {
- //start a new session
- $_SESSION["suppLogin"] = "guest";
- }
- function logIn($user) {
- $_SESSION["suppLogin"] = $user;
- }
- function verifyLogin($user, $pass) {
- $hash = hash('sha256',strtoupper($user)." insert salt here ".md5(strtolower($pass)));
- $mysqli = new mysqli("127.0.0.1","root"," hidden "," hidden ");
- if($mysqli->connect_errno){
- echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
- return false;
- }
- if(!($stmt = $mysqli->prepare("SELECT * FROM users WHERE username=(?) && password=(?)"))){
- echo "Query preparation failed: (" . $mysqli->errno . ") " . $mysqli->error;
- return false;
- }
- if(!$stmt->bind_param("ss",$user,$hash)){
- echo "Failed to bind parameters: (" . $mysqli->errno . ") " . $mysqli->error;
- return false;
- }
- if(!$stmt->execute()){
- echo "Failed to execute statement: (" . $mysql->errno . ") " . $mysqli->error;
- return false;
- }
- $stmt->store_result();
- if($stmt->num_rows() != 1){
- echo "The information you provided was unable to authenticate your credentials. <br />";
- return false;
- }
- $mysqli->close();
- return true;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement