Guest User

Untitled

a guest
Jun 10th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. {
  2.  
  3. <
  4. ?php
  5. session_start();
  6.  
  7. $error = ""; // store error message
  8.  
  9. if(isset($_POST['submit']))
  10. {
  11.  
  12. if(empty($_POST['username']) || empty($_POST['password']))
  13.  
  14. {
  15.  
  16. $error = "Username and password is invalid";
  17.  
  18. echo "$error";
  19.  
  20. }
  21.  
  22. else
  23.  
  24. {
  25.  
  26. $username = $_POST['username'];
  27.  
  28. $password = $_POST['password'];
  29.  
  30. $conn = mysql_connect('localhost','','','practice');
  31.  
  32. if($conn==true)
  33.  
  34. {
  35.  
  36. $query = mysql_query($conn,"select * from employee where username=$username AND password=$password");
  37.  
  38. $rows = mysql_num_rows($query);
  39.  
  40. if($rows == 1)
  41.  
  42. {
  43.  
  44. $_SESSION['login_user'] = $username;
  45.  
  46. header("location:profile.php");
  47.  
  48. }
  49.  
  50. else
  51.  
  52. {
  53.  
  54. $error = "Username and Password is Invalid";
  55.  
  56. }
  57.  
  58. }
  59.  
  60. else
  61.  
  62. {
  63.  
  64. echo "error";
  65.  
  66. }
  67.  
  68. mysql_close($conn);
  69.  
  70. }
  71.  
  72. }
  73.  
  74. ?>
  75.  
  76. }
Add Comment
Please, Sign In to add comment