Advertisement
Guest User

Untitled

a guest
Jul 7th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. <?php
  2. require_once('db.php');
  3. include('functions.php');
  4.  
  5. if(isset($_POST['Login']))
  6. {
  7. if($_POST['username']!='' && $_POST['password']!='')
  8. {
  9. //Use the input username and password and check against 'users' table
  10. $query = mysql_query('SELECT ID, Username, Active FROM users WHERE Username = "'.mysql_real_escape_string($_POST['username']).'" AND Password = "'.mysql_real_escape_string(md5($_POST['password'])).'"');
  11.  
  12. if(mysql_num_rows($query) == 1)
  13. {
  14. $row = mysql_fetch_assoc($query);
  15. if($row['Active'] == 1)
  16. {
  17. $_SESSION['user_id'] = $row['ID'];
  18. $_SESSION['logged_in'] = TRUE;
  19. header("Location: members.php");
  20. }
  21. else {
  22. $error = 'Your membership was not activated. Please open the email that we sent and click on the activation link';
  23. }
  24. }
  25. else {
  26. $error = 'Login failed !';
  27. }
  28. }
  29. else {
  30. $error = 'Please user both your username and password to access your account';
  31. }
  32. }
  33. ?>
  34.  
  35. <?php if(isset($error)){ echo $error;}?>
  36. <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
  37. <input type="text" id="username" name="username" size="32" value="" />
  38. <input type="password" id="password" name="password" size="32" value="" />
  39. <input type="submit" name="Login" value="Login" />
  40. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement