Advertisement
Guest User

Untitled

a guest
Aug 8th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.12 KB | None | 0 0
  1. <?php
  2.  
  3. include_once("connectapp.php");
  4.  
  5. $tbl_name="User"; // Table name
  6.  
  7.  
  8. // username and password sent from form
  9. $myusername=$_POST['myusername'];
  10. $mypassword=$_POST['mypassword'];
  11.  
  12.  
  13. $myusername = stripslashes($myusername);
  14. $mypassword = stripslashes($mypassword);
  15. $myusername = mysql_real_escape_string($myusername);
  16. $mypassword = mysql_real_escape_string($mypassword);
  17.  
  18. $sql="SELECT * FROM $tbl_name WHERE UserName='$myusername' and Password='$mypassword'";
  19. $result=mysql_query($sql);
  20.  
  21. // Mysql_num_row is counting table row
  22. $count=mysql_num_rows($result);
  23. // If result matched $myusername and $mypassword, table row must be 1 row
  24.  
  25. if($count==1){
  26. // Register $myusername, $mypassword and redirect to the correct page
  27. session_register("myusername");
  28. session_register("mypassword");
  29.  
  30.  
  31. $sql="SELECT * FROM $tbl_name WHERE Permission='$user_level'";
  32.  
  33.  
  34. if($user_level ==1) {
  35.  
  36.  
  37. header("location:guestmain.html"){
  38.  
  39. }
  40.  
  41. elseif($user_level ==2 {
  42.  
  43. header("location:registeredmain.html"){
  44.  
  45. } elseif($user_level ==3 {
  46.  
  47. header("location:main.html");
  48.  
  49.  
  50.  
  51.  
  52. }
  53. else {
  54. echo "Wrong Username or Password";
  55. }
  56. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement