Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.34 KB | None | 0 0
  1. <?php
  2. $post = filter_input_array(INPUT_POST, [
  3.     'login'=>FILTER_SANITIZE_STRING,
  4.     'password'=>FILTER_UNSAFE_RAW
  5. ]);
  6. $user = "root";
  7. $pass = "1";
  8. try {
  9.     require_once("modules/connect.php");
  10.     $pss = sha1($post['password']); //зашифрованный пароль
  11.     $sth = $dbh->prepare("SELECT * FROM test WHERE login=?");
  12.     $sth->execute([$post['login']]);
  13.     $pth = $dbh->prepare("SELECT * FROM test WHERE pass=?");
  14.     $pth->execute([$post['password']]);
  15.     $result = $sth->rowCount(); //вывод кол-ва записей
  16.     $resultp = $pth->rowCount(); //вывод кол-ва записей
  17.     print_r($result);
  18.     if ($result==0) { //проверка
  19.         echo "Такого пользователя нету";
  20.         return;
  21.     } else {
  22.         if ($resultp==0) { //проверка
  23.             echo "Неверный пароль";
  24.             return;
  25.         } else {
  26.             echo "ok";
  27.             setcookie("test",$post['login'],time()+3600);
  28.         }
  29.         //setcookie("test",$post['login'],time()+3600);
  30.         //header("Location: pass.html");
  31.         if ($post['login']=='root') {
  32.             header("Location: pages.php");
  33.         }
  34.         else {
  35.             header("Location: lk.php");
  36.         }
  37.              
  38.     }
  39. } catch (PDOException $e) {
  40.     echo $e->getMessage();
  41. }
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement