Advertisement
Guest User

Untitled

a guest
May 30th, 2017
64
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. ?>
  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. $user1=$_POST["user"];
  17. $pass1=$_POST["pass"];
  18. $user=mysql_real_escape_string($user1);
  19. $pass=mysql_real_escape_string($pass1);
  20. $con=mysql_connect("localhost","root");
  21. if(!$con)
  22. {
  23. die('Could not Connect:'.mysql_error());
  24. }
  25. mysql_select_db("cms", $con);
  26. $result = mysql_query("SELECT Password FROM login WHERE Username = '$user'") or die('No such user');
  27. $row=mysql_fetch_assoc($result);
  28. $passtest=$row["Password"];
  29. if($row==false)
  30. {
  31. echo("Wrong password<br />");
  32. }
  33. else if($row==true)
  34. {
  35. if($pass!=$passtest)
  36. {
  37. echo("Wrong password and/or username");
  38. }
  39. else if($pass==$passtest)
  40. {
  41. $login=true;
  42. echo("Logged In successfully");
  43. $query = mysql_query("SELECT * from login WHERE Username = '$user'") or die(mysql_error);
  44. $row = mysql_fetch_assoc($query);
  45. $status = $row["Status"];
  46. if($status==1)
  47. {
  48. echo("<br />You are admin");
  49. header("Location:admin.php");
  50. $_SESSION['ID']=1;
  51.  
  52. }
  53. else
  54. {
  55. echo("<br />You are not admin.");
  56. echo("<a href='noruser.php'>Proceed</a>");
  57. $_SESSION['ID']=0;
  58. header("Location:admin.php");
  59. }
  60. }
  61. else
  62. {
  63. echo("Wrong password");
  64. }
  65. }
  66.  
  67. mysql_close($con);
  68. x
  69. ?>
  70. </body>
  71. </html>
  72.  
  73. Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in D:\xampp\htdocs\logintest.php on line 19
  74. Wrong password
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement