Advertisement
Guest User

Untitled

a guest
May 1st, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4.  
  5. include('index-redirect.php');
  6.  
  7. include('header.php');
  8.  
  9. if ($user)
  10. {
  11. die("You're already logged in! You are being redirected to the home page. If you are not redirected, <a href='index.php'>click here</a>.");
  12. }
  13. else
  14.  
  15. $username = $_POST['username'];
  16. $password = $_POST['password'];
  17.  
  18. if ($username&&password)
  19. {
  20.  
  21. $connect = mysql_connect("localhost","sourpic_sourvid","sourvid") or die("Couldn't connect to the database - Please try again later.");
  22. mysql_select_db("sourpic_sourvid") or die("Couldn't find the database.");
  23.  
  24. $query = mysql_query("SELECT * FROM users WHERE username ='$username'");
  25.  
  26. $numrows = mysql_num_rows($query);
  27.  
  28. if ($numrows!=0)
  29. {
  30.  
  31. while ($row = mysql_fetch_assoc($query))
  32. {
  33. $dbusername = $row['username'];
  34. $dbpassword = $row['password'];
  35. $verifyed = $row['valid'];
  36. }
  37.  
  38. //check to see if they match!
  39. if (strtolower($username)==$dbusername&&md5($password)==$dbpassword&&$valid=1)
  40. {
  41. echo "You're in! You are now being redirected to the home page. If you are not redirected, <a href='index.php'>click here</a>.";
  42. $_SESSION['username']=strtolower($username);
  43. }
  44. else
  45. echo "Incorrect password!";
  46.  
  47. }
  48. else
  49. die("That user doesn't exist!");
  50.  
  51. }
  52. else
  53. die("Please enter a username and password!");
  54.  
  55. include('footer.php');
  56.  
  57. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement