Advertisement
Guest User

Untitled

a guest
Aug 5th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. //edited by thinkfeed.info u better know it
  5. //problem?
  6.  
  7. include "db_connect.php";
  8. if(!$_POST['submit'])
  9. {
  10. ?>
  11. <html>
  12. <b><Login</b>
  13. <form method="post" action="index.php">
  14. Username<input type="text" name="username" maxlength="16">
  15. Password<input type="password" name="password" maxlength="16">
  16. <input type="submit" name="submit" value="Login">
  17. </form>
  18. <a href="register.php">Register Here</a>
  19. </html>
  20.  
  21. <?php
  22. }
  23. else
  24. {
  25. $user = protect($_POST['username']);
  26. $pass = protect($_POST['password']);
  27.  
  28. if($user && $pass)
  29. {
  30. $pass = md5($pass); //compare the encrypted password
  31. $sql="SELECT id,username FROM `users` WHERE `username`='$user' AND `password`='$pass'";
  32. $query=mysql_query($sql) or die(mysql_error());
  33.  
  34. if(mysql_num_rows($query) == 1)
  35. {
  36. $row = mysql_fetch_assoc($query); // mysql_fetch_assoc gets the value for each field in the row
  37. $_SESSION['id'] = $row['id']; //creates the first session var
  38. $_SESSION['username'] = $row['username']; // second session var;
  39.  
  40. echo '<script type="text/javascript">window.location="home.php"</script>';
  41. }
  42. else
  43. {
  44. echo '<script type="text/javascript">';
  45. alert("Username and password combination is incorrect!");
  46. window.location="index.php".'</script>';
  47. }
  48. }
  49. else
  50. {
  51. echo '<script type="text/javascript">';
  52. alert("You need to gimme a username AND password!!");
  53. window.location="index.php".'</script>';
  54. }
  55. }
  56. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement