Advertisement
Guest User

Untitled

a guest
May 30th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. <?php
  2. ob_start();
  3. ?>
  4. <html>
  5. <body>
  6. <?php
  7. if(!isset($_SESSION['ID']))
  8. {
  9. echo('<form action="logintest.php" method="post">');
  10. echo('Username:<input type="text" name="user" /><br />');
  11. echo('Password:<input type="password" name="pass" /><br /><input type="Submit" value="Login" /></form><br />');
  12.  
  13. }
  14. ?>
  15. <?php
  16. $user=$_POST["user"];
  17. $pass=$_POST["pass"];
  18. $con=mysql_connect("localhost","root");
  19. if(!$con)
  20. {
  21. die('Could not Connect:'.mysql_error());
  22. }
  23. mysql_select_db("cms", $con);
  24. $result = mysql_query("SELECT Password FROM login WHERE Username = '$user'") or die('No such user');
  25. $row=mysql_fetch_assoc($result);
  26. $passtest=$row["Password"];
  27. if($row==false)
  28. {
  29. echo("Wrong password<br />");
  30. }
  31. else if($row==true)
  32. {
  33. if($pass!=$passtest)
  34. {
  35. echo("Wrong password and/or username");
  36. }
  37. else if($pass==$passtest)
  38. {
  39. $login=true;
  40. echo("Logged In successfully");
  41. $query = mysql_query("SELECT * from login WHERE Username = '$user'") or die(mysql_error);
  42. $row = mysql_fetch_assoc($query);
  43. $status = $row["Status"];
  44. if($status==1)
  45. {
  46. echo("<br />You are admin");
  47. header("Location:admin.php");
  48. $_SESSION['ID']=1;
  49.  
  50. }
  51. else
  52. {
  53. echo("<br />You are not admin.");
  54. echo("<a href='noruser.php'>Proceed</a>");
  55. $_SESSION['ID']=0;
  56. header("Location:admin.php");
  57. }
  58. }
  59. else
  60. {
  61. echo("Wrong password");
  62. }
  63. }
  64.  
  65. mysql_close($con);
  66. x
  67. ?>
  68. </body>
  69. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement