Advertisement
Guest User

Untitled

a guest
Sep 28th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. include("db.php");
  5.  
  6. mysql_select_db("youscoop") or die("Could not select database");
  7.  
  8. if(isset($_POST['submit'])){
  9. $username = mysql_real_escape_string($_POST['username']);
  10. $password = mysql_real_escape_string($_POST['password']);
  11.  
  12. $query= mysql_query("SELECT id,user FROM user_info WHERE user='$username' AND pass = '$password' LIMIT 1");
  13. $found = mysql_num_rows($query);
  14. if($found == 1){
  15. $row = mysql_fetch_assoc($query);
  16. //start sessioning the id and username
  17. $_SESSION['id'] = $row['id'];
  18. $_SESSION['user'] = $row['user'];
  19.  
  20. header('Location: index.php');
  21.  
  22.  
  23. }else{
  24. echo "Login failed";
  25. }
  26. }
  27. ?>
  28.  
  29.  
  30. <form method="POST" action="">
  31. <table>
  32. <tr>
  33. <td>Username</td>
  34. <td> <input type="text" name="username" id="username"><br/></td>
  35. </tr>
  36. <tr><td>Password</td>
  37. <td> <input type="password" name="password" id="password"><br/></td>
  38. </tr>
  39. <tr>
  40. <td></td>
  41. <td>
  42. <input type="submit" id="submit" name="submit" value="login">
  43. </td>
  44. </tr>
  45.  
  46. </table>
  47. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement