Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $post = filter_input_array(INPUT_POST, [
- 'login'=>FILTER_SANITIZE_STRING,
- 'password'=>FILTER_UNSAFE_RAW
- ]);
- $user = "root";
- $pass = "1";
- try {
- require_once("modules/connect.php");
- $pss = sha1($post['password']); //зашифрованный пароль
- $sth = $dbh->prepare("SELECT * FROM test WHERE login=?");
- $sth->execute([$post['login']]);
- $pth = $dbh->prepare("SELECT * FROM test WHERE pass=?");
- $pth->execute([$post['password']]);
- $result = $sth->rowCount(); //вывод кол-ва записей
- $resultp = $pth->rowCount(); //вывод кол-ва записей
- print_r($result);
- if ($result==0) { //проверка
- echo "Такого пользователя нету";
- return;
- } else {
- if ($resultp==0) { //проверка
- echo "Неверный пароль";
- return;
- } else {
- echo "ok";
- setcookie("test",$post['login'],time()+3600);
- }
- //setcookie("test",$post['login'],time()+3600);
- //header("Location: pass.html");
- if ($post['login']=='root') {
- header("Location: pages.php");
- }
- else {
- header("Location: lk.php");
- }
- }
- } catch (PDOException $e) {
- echo $e->getMessage();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement