Advertisement
Guest User

Untitled

a guest
Aug 7th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. <?php
  2. include_once('_head.php');
  3.  
  4. if(isset($_POST['submit'])){
  5. /* Post entered data */
  6. $username = $_POST['username'];
  7. $password = md5($_POST['password']);
  8.  
  9. /* Check if data is in the database*/
  10. $query=mysql_query("SELECT * FROM users where username='$username' AND password='$password'");
  11. $count=mysql_num_rows($query);
  12.  
  13. /* If username and password match with those in database, user is take to the members area */
  14. if($count == 1) {
  15. $_SESSION['username'] = $_POST['username'];
  16. Header("location: members.php");
  17. }
  18. /* Otherwise , user is redirected to the login form */
  19. else
  20. {
  21. echo "Username or password is incorrect";
  22. echo "<br />";
  23. echo "<a href='login.php'>Try again</a>";
  24. }
  25. }
  26. else
  27. {
  28. ?>
  29. <html>
  30. <body>
  31. <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
  32. <table border="0">
  33. <tr>
  34. <td>Username: </td><td><input type="text" name="username" />
  35. </td>
  36. </tr>
  37. <tr>
  38. <td>Password: </td><td><input type="password" name="password" />
  39. </td>
  40. </tr>
  41. <tr>
  42. <td>
  43. </td>
  44. <td><input type="submit" value="Login" />
  45. </td>
  46. </tr>
  47. <tr>
  48. <td><a href="signup.php">Signup</a>
  49. </td>
  50. </tr>
  51. </table>
  52. </form>
  53. </body>
  54. </html>
  55. <?php
  56. }
  57. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement