Advertisement
Guest User

Untitled

a guest
Sep 20th, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. <?php
  2.  
  3. if ( (isset($_POST['username'])) && (isset($_POST['password'])) )
  4. {
  5.  
  6. $username=$_POST['username'];
  7. $password=$_POST['password'];
  8.  
  9. $password_hash=md5($password);
  10. if(!empty($username)&&!empty($password))
  11.  
  12. {
  13. $query="SELECT `id` , `Password` FROM `students` WHERE `Username`='$username' AND `Password`='$password_hash' ";
  14.  
  15. if ($query_run=mysqli_query($connect,$query))
  16. {
  17. $query_num_rows=mysqli_num_rows($query_run);
  18.  
  19.  
  20. if ($query_num_rows==0)
  21. {
  22. echo ' Invalid Username/Password Combination';
  23. }
  24. else if ($query_num_rows==1)
  25. {
  26. $user_id=mysql_result($query_run,0,'id');
  27. $_SESSION['user_id']=$user_id;
  28. header('Location:Index.php');
  29.  
  30. }
  31. }
  32.  
  33. }
  34. else
  35. {
  36. echo 'You Must Enter a UserName and Password';
  37. }
  38. }
  39.  
  40. ?>
  41.  
  42.  
  43. <form action="<?php echo $current_file; ?>" method="POST">
  44.  
  45. Username : <input type="username" name="username">
  46. Password : <input type="password" name="password">
  47. <input type="submit" Value="Login">
  48.  
  49. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement