Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(-1);
- require('password.php');
- //include('iflogin.php');
- include('config.php');
- $pwd = $_POST['password'];
- $name = $_POST['email'];
- $con = new PDO('mysql:host='.DB_HOST.';dbname='.DB_DB.';charset=utf8_general_ci', DB_USERNAME, DB_PASSWORD, array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
- $con->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
- try{
- $sql = $con->prepare('SELECT * FROM users WHERE name=:name OR email=:name');
- $sql->bindValue(':name', $name);
- $result = $sql->fetch();
- }catch(PDOException $ex){
- echo 'Error! '.$ex->getMessage();
- }
- // check password
- if(password_verify($pwd,$result['password'])){
- //calculate when the session should expire
- $expires = time() + (60 * SESSION_LENGTH);
- //log in
- $sql = $con->prepare("INSERT INTO `active_users` (`user`,`session_id`,`expires`) VALUES (`:user`,`:id`,`:expires`)");
- $sql->bindValue(':user', $result['id']);
- $sql->bindValue(':id', session_id());
- $sql->bindValue(':expires', $expires);
- $sql->execute();
- if($result['side']){
- $side = 'heaven';
- }else{
- $side = 'hell';
- }
- // redirect to game
- header('Location: /'.$side);
- }else{
- //password incorrect
- die("INCORRECT PASSWORD YOU BASTARD!");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement