Advertisement
Guest User

Php call

a guest
Oct 21st, 2019
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Login 3</title>
  6. </head>
  7. <body>
  8. <?php
  9. session_start();
  10. if($_SESSION['userid']>0){
  11. echo "<a href='logout.php'>Выход</a>";
  12.  
  13. }
  14. else{
  15. if(($_POST['username'] == '') or ($_POST['password'] == '')){
  16. echo "
  17. <form action='./login3.php' method='post'>
  18. Логин: <input type='text' name='username'><br>
  19. Пароль: <input type='text' name='password'><br>
  20. <input type='submit' name='submite' value='Войти'>
  21. </form>
  22. ";
  23. }
  24. else{
  25. $username = $_POST['username'];
  26. $userpass = $_POST['password'];
  27.  
  28. require_once 'connect.php';
  29.  
  30. $sql = "SELECT * FROM users WHERE login='$username' and password='$userpass' ";
  31.  
  32. $result = $link -> query($sql);
  33. $row = $result -> fetch_assoc();
  34.  
  35. if($row){
  36. echo "Добро пожаловать ", $row['login'], "<br>", "Ваш id ", $row['id'];
  37. $_SESSION['userid'] = $row['id'];
  38. }
  39. else{
  40. echo "Вы неправильно ввели имя пользователя или пароль", "<br>", "<a href='login3.php'>Вренуться</a>";
  41.  
  42. }
  43.  
  44. $result->close();
  45. $link->close();
  46.  
  47. }
  48. }
  49.  
  50. ?>
  51. </body>
  52. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement