Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require_once("DB.php");
  4.  
  5. if ($_SESSION['logined'] !== null) {
  6. $u = $_SESSION['logined'];
  7. header("Location: home.php",true,303);
  8. }
  9. if (isset($_POST['username']) && isset($_POST['pass']))
  10. {
  11. $username=$_POST['username']=trim($_POST['username']);
  12. $pass=$_POST['pass']=trim($_POST['pass']);
  13. $DB = DB::con();
  14. $sql = $DB->prepare("select * from students where login = ? and password = ?");
  15. $sql->execute(array($username, md5($pass)));
  16. $sql->setFetchmode(PDO::FETCH_ASSOC);
  17. foreach ($sql as $row)
  18. {
  19. if ($username==$row['login'])
  20. {
  21. $_SESSION['logined']=$username;
  22. header("Location: p_home.php");
  23. }
  24. else
  25. {die('Такой логин с паролем не найдены в базе данных.');
  26. }
  27. }
  28. }
  29.  
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement