Advertisement
gayanov

Untitled

Feb 2nd, 2017
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.36 KB | None | 0 0
  1. <?php
  2.   include "../config.php";
  3.  
  4. try {
  5.     $db = new PDO('mysql:host=' . $settings['db']['host'] . ';dbname=' . $settings['db']['dbname'], $settings['db']['user'], $settings['db']['password']);
  6. } catch (PDOException $e) {
  7.     echo '<b>Ошибка с соединении с бд</b>: ' . $e->getMessage();
  8. }
  9.  
  10. if (isset($_POST['login'])) {
  11.     $login = $_POST['login'];
  12.     if ($login == '') {
  13.         unset($login);
  14.         exit ("<script>
  15.         toastr.error('Введите пожалуйста логин!')</script><br>");
  16.     }
  17. }
  18. if (isset($_POST['password'])) {
  19.     $password=$_POST['password'];
  20.     if ($password =='') {
  21.         unset($password);
  22.         exit ("<script>
  23.         toastr.error('Введите пароль')</script><br>");
  24.     }
  25. }
  26.  
  27. $login = stripslashes($login);
  28. $login = htmlspecialchars($login);
  29.  
  30. $password = stripslashes($password);
  31. $password = htmlspecialchars($password);
  32.  
  33.  
  34. $login = trim($login);
  35. $password = trim($password);
  36.  
  37. $user = $db->query('SELECT * from users WHERE `login` = '.$login.' AND password='.$password.' AND activation=1');
  38. $login = "" . $row['login'] ."";
  39. if (empty($login)){
  40.     exit ("<script>
  41.         toastr.danger('not', {timeOut: 5000})</script><br>");
  42. }
  43. //else {
  44.  
  45.    
  46.    // $_SESSION['password']=$password;
  47.     //$_SESSION['login']=$login;
  48.    // $_SESSION['id']=$id_user['id'];
  49.          
  50. //}
  51. //echo "<meta http-equiv='Refresh' content='0; URL=/'>";
  52. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement