Advertisement
Guest User

Untitled

a guest
May 19th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. <?php
  2. if (isset($_POST['submit']))
  3. {
  4. $username = $_POST['username'];
  5. $password = $_POST['password'];
  6.  
  7. $query = "select count(*) from tbl_users where username = '$username' and password = '$password'";
  8.  
  9. $result = mysqli_query($conn, $query) or die ("Error in query: ".mysqli_error($conn));
  10. $row = mysqli_fetch_row($result);
  11. $counter = $row[0];
  12.  
  13. echo $counter;
  14.  
  15. if ($counter>0){
  16. $_SESSION['valid_user']=$username;
  17. }
  18.  
  19.  
  20. if (isset($_SESSION['valid_user']))
  21. {
  22. echo "You are logged in as: $_SESSION[valid_user]<br />";
  23. echo "<a href = 'logout.php'>Log Out</a><br />";
  24.  
  25. }
  26.  
  27.  
  28. else{
  29. if((isset($username)) && (isset($password))){
  30. echo "Could not log you in. Incorrect username or password<br />";
  31. }
  32. else{
  33. echo "You are not logged in. <br />";
  34. }
  35. }
  36. }
  37.  
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement