Advertisement
Guest User

Untitled

a guest
Jun 7th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. <?php
  2. ob_start();
  3. if(isset($_SESSION['user'])){
  4. if($_SESSION['user']==1){
  5. header("admin.php");
  6. }
  7. else if($_SESSION['user']==0) {
  8. header("noruser.php");
  9. }
  10. }
  11. ?>
  12. <html>
  13. <body>
  14. <form action="login.php" method="post">
  15. Username:<input type="text" name="user" />
  16. Password:<input type="password" name="pass" /><br><br><br>
  17. <input type="Submit" value="login" />
  18. </form>
  19. <?php
  20. if(!isset($_SESSION['user'])){
  21. $user=htmlentities($_POST["user"]);
  22. $pass=htmlentities($_POST["pass"]);
  23. $con=mysql_connect("localhost","root");
  24. if(!$con){
  25. die('Could not Connect:'.mysql_error());
  26. }
  27. mysql_select_db("site", $con);
  28. $result = mysql_query("SELECT Password FROM login1 WHERE Username = '$user'") or die('No such user');
  29. $row=mysql_fetch_assoc($result);
  30. $passtest=$row["Password"];
  31. if(empty($user) || empty($pass)){
  32. echo("<div id='alert' style='background-color:red;font-size:100px;font-family:Bleeding Cowboys;width:1430px;height:140px;'><center>Please enter all fields</center><div>");
  33. }
  34. else if($pass !== $passtest){
  35. echo("<div id='alert1' style='background-color:red;font-size:100px;font-family:Bleeding Cowboys;width:1430px;height:230px;'><center>Wrong password and/or username</center></div>");
  36. }
  37. else if($pass == $passtest)
  38. {
  39. $result=mysql_query("SELECT Status from login1 WHERE Username='$user'");
  40. $row1=mysql_fetch_assoc($result);
  41. echo("Logged in");
  42. echo("<br />");
  43. if($row1['Status'] == 1){
  44. $_SESSION['user'] = 1;
  45. echo("<div class='alert'>You are admin</div>");
  46. header("admin.php");
  47. }
  48. else if($row1['Status'] == '0'){
  49. $_SESSION['user'] = 0;
  50. echo("shit");
  51. header("noruser.php");
  52. }
  53. }
  54. mysql_close($con);
  55. echo("<br /><br /><br /><br />");
  56. }
  57. else{
  58. echo("You have already logged in and are not supposed to login again, please disble the option in your browser where it disallows sites to automatically redirect you and reload the page or directly go to the page you are supposed to if you remember the URL. Thank You.");
  59. }
  60. ?>
  61. </body>
  62. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement