Advertisement
Guest User

Untitled

a guest
Jul 18th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.79 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. $loginpopup = 'Login Success';
  5. $failpopup = 'Wrong Username or Password';
  6. if(!$con)
  7. {
  8. die("Error connection" . mysqli_connect_error());
  9.  
  10. }
  11. if (isset($_POST['submitlogin']))
  12. {
  13.  
  14. $login = "SELECT * from admin where username = '$_POST[user]' AND password ='$_POST[pass]'";
  15.  
  16. $getuser = mysqli_query($con,$login) or die(mysql_error());
  17. while($row = mysqli_fetch_array($getuser))
  18. {
  19. if($row==0)
  20. {
  21. echo "<SCRIPT>alert('$failpopup');</SCRIPT>";
  22. header("location:index.php");
  23. }
  24. else
  25. {
  26. echo "<SCRIPT>alert('$loginpopup');</SCRIPT>";
  27. header("location:home.php");
  28. }
  29. }
  30. }
  31. ?>
  32.  
  33. include('movieshub/includes/config.php');
  34. if ($getuser = mysqli_query($con,$login)) { // check if the query succeeded running
  35. $count = mysqli_num_rows($getuser);
  36. if ($count == 0 ) {
  37.  
  38. echo "<SCRIPT>alert('$failpopup');</SCRIPT>";
  39. header("location:index.php");
  40.  
  41. } else {
  42.  
  43. while($row = mysqli_fetch_array($getuser))
  44. { //output data }
  45. echo "<SCRIPT>alert('$loginpopup');</SCRIPT>";
  46. header("location:home.php");
  47. }
  48. }
  49. } else {
  50. echo "query failed to run";
  51. }
  52.  
  53. <?php
  54.  
  55. //if your are using wamp then let $servername,$username and $password be same as below otherwise change them.
  56.  
  57. $servername = "localhost"; //insert your severname at the place of localhost
  58. $username = "root"; //insert your username at the place of root
  59. $password = ""; //insert your password at the place of ""
  60.  
  61. // Create connection
  62. $con = mysqli_connect($servername, $username, $password);
  63.  
  64. //select database
  65. mysqli_select_db($con,"test"); //here enter your database name at the place of test
  66.  
  67. // Check connection
  68. if (!$con) {
  69. die("Connection failed: " . mysqli_connect_error());
  70. }
  71.  
  72. $loginpopup = 'Login Success';
  73. $failpopup = 'Wrong Username or Password';
  74.  
  75.  
  76.  
  77.  
  78. if (isset($_POST['submitlogin']))
  79. {
  80. $user=$_POST["user"];
  81. $pass=$_POST["pass"];
  82.  
  83. $login = "SELECT * from admin where username=$user AND password=$pass";
  84.  
  85. $getuser = mysqli_query($con,$login);
  86.  
  87. $row=mysqli_affected_rows($con);
  88. if($row>1)
  89. {
  90. echo "<SCRIPT>alert('$loginpopup');</SCRIPT>";
  91. header("location:home.php");
  92.  
  93.  
  94. }
  95.  
  96. else
  97. {
  98. echo "<SCRIPT>alert('$failpopup');</SCRIPT>";
  99. header("location:index.php");
  100. }
  101.  
  102. }
  103. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement