Advertisement
Guest User

Untitled

a guest
Jan 6th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. <?php
  2.  
  3. session_start(); // Starting Session
  4. $error=''; // Variable To Store Error Message
  5. if (isset($_POST['submit'])) {
  6. if (empty($_POST['username']) || empty($_POST['password'])) {
  7. $error = "Username or Password is invalid";
  8. }
  9. else
  10. {
  11. // Definir isto $username and $password
  12. $username=$_POST['username'];
  13. $password=$_POST['password'];
  14. // estabelecer conexao com estes parameteros
  15. $connection = mysqli_connect('localhost','root','','fitdb');
  16. // Stripslashes para questoes de segurança SQL
  17. $username = stripslashes($username);
  18. $password = stripslashes($password);
  19. $username = mysqli_real_escape_string($connection, $username);
  20. $password = mysqli_real_escape_string($connection, $password);
  21.  
  22.  
  23. // Query para buscar informação
  24. $query = mysqli_query($connection, "SELECT * FROM tbluser WHERE Username = \"".$_POST["username"]."\" AND Password = \"".$_POST["password"]."\";");
  25. $rows = mysqli_num_rows($query);
  26. if ($rows == 1) {
  27. $_SESSION['login_user']= $username; // Inicializar sessão
  28. header("location: indexPAPWithProfile.php"); // redirect
  29. echo $username;
  30. } else {
  31.  
  32. $error = "Username or Password is invalid";
  33.  
  34. }
  35. mysqli_close($connection); // close
  36. }
  37. }
  38.  
  39.  
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement