Advertisement
Guest User

Untitled

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