Advertisement
Guest User

Untitled

a guest
Jun 25th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include "db_connect.php";
  4. ?>
  5.  
  6. <html>
  7. <body>
  8.  
  9. <h3>Login form:</h3>
  10.  
  11. <form action='index.php' method='POST'>
  12. User:
  13. <input type="text" name="user">
  14. Pass:
  15. <input type="password" name="pass">
  16. <br><br>
  17. <input type="submit" value="Login">
  18. </form>
  19.  
  20. </body>
  21. </html>
  22.  
  23. <?php
  24. session_start();
  25.  
  26. $_SESSION['user'] = $_POST['user'];
  27. $_SESSION["pass"] = $_POST['pass'];
  28.  
  29. $session_user = $_SESSION['user'];
  30. $session_pass = $_SESSION['pass'];
  31.  
  32. ?>
  33.  
  34. <html>
  35. <head>
  36. </head>
  37.  
  38. <body>
  39. </body>
  40.  
  41. </html>
  42.  
  43.  
  44. <?php
  45. include "../db_connect.php";
  46.  
  47.  
  48. $sql = "SELECT * FROM user WHERE (user = '$session_user' && password = '$session_pass')";
  49. $result = $conn->query($sql);
  50.  
  51.  
  52. if ($result->num_rows > 0) {
  53.  
  54. // output data of each row
  55. while($row = $result->fetch_assoc()) {
  56.  
  57. include "index_detail.php";
  58. }
  59. } else {
  60. echo "There was an error logging in.";
  61. }
  62.  
  63. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement