Advertisement
Guest User

Untitled

a guest
Oct 25th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $error = '';
  4.  
  5. if(isset($_POST['submit'])){
  6. if(empty($_POST['form_username']) || empty($_POST['form_password'])){
  7. $error = "Username or Password is invalid!";
  8. }else{
  9. // ******************* connection part *******************
  10. $servername = "localhost";
  11. $username = "one4112";
  12. $password = "JtQbDTAHY9aSQIUP";
  13. $dbname = "14112";
  14.  
  15. $connection = new mysqli($servername, $username, $password, $dbname);
  16.  
  17. if ($connection->connect_error){
  18. die("Connection failed: " . $connection->connect_error);
  19. }
  20. // **************** end of connection part ***************
  21.  
  22. $checkUsername = $_POST['form_username'];
  23. $checkPassword = $_POST['form_password'];
  24.  
  25. echo $checkUsername;
  26. echo "<br>";
  27. echo $checkPassword;
  28.  
  29. $sql_query = "SELECT * FROM Login_Table
  30. WHERE Login_Username = '$checkUsername'
  31. AND Login_Password = '$checkPassword'";
  32.  
  33. $result = $connection->query($sql_query);
  34. if($result->num_rows > 0){
  35. echo "YES";
  36. $_SESSION['login_user'] = $checkUsername;
  37. header('location: index.php');
  38. }else{
  39. echo "Incorrect username or password!";
  40. }
  41. $connection->close();
  42. }
  43. }
  44. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement