Guest User

Untitled

a guest
Feb 12th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. $(document).ready(function() {
  2. $("#buttonLogin").click(function() {
  3. var action = $("#formLogin").attr('action');
  4. var form_data = {
  5. username: $("#login").val(),
  6. password: $("#password").val(),
  7. is_ajax: 1
  8. };
  9.  
  10. $.ajax({
  11. type: "POST",
  12. url: action,
  13. data: form_data,
  14. success: function(response) {
  15. if (response == 'success') {
  16. $("#message")
  17. .html("<p class='success'>Você foi logado com êxito!</p>");
  18. } else {
  19. $("#message")
  20. .html("<p class='error'>Nome de usuário/senha inválido.</p>");
  21. }
  22. }
  23. });
  24. return false;
  25. });
  26. });
  27.  
  28. <?php
  29.  
  30. $is_ajax = $_REQUEST['is_ajax'];
  31.  
  32. if (isset($is_ajax) && $is_ajax) {
  33.  
  34. $email = $_REQUEST['username'];
  35. $password = $_REQUEST['password'];
  36.  
  37. // colocar dados em um arquivo externo
  38. $conexao_bd = new Conexaobd('admin', 'g1234', 'localhost', 'guestbookbd');
  39. $result = $conexao_bd->consultaLogin();
  40.  
  41. if ($result == 1) {
  42. echo 'success';
  43. }
  44. }
  45.  
  46. function __construct($usuario, $senha, $sid, $banco)
  47. {
  48. $this->usuario = $usuario;
  49. $this->senha = $senha;
  50. $this->sid = $sid;
  51. $this->banco = $banco;
  52. //$this->conecta();
  53. }
  54.  
  55. function consultaLogin()
  56. {
  57. return 1;
  58. }
Add Comment
Please, Sign In to add comment