Advertisement
Guest User

Untitled

a guest
Jun 15th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. .on('success.form.fv', function(e) {
  2. // Prevent form submission
  3. e.preventDefault();
  4.  
  5. // Get the form instance
  6. var $form = $(e.target);
  7.  
  8. // Get the BootstrapValidator instance
  9. var fv = $form.data('formValidator');
  10.  
  11. // Use Ajax to submit form data
  12. $.post($form.attr('action'), $form.serialize(), function(result) {
  13. console.log(result);
  14. if(result === 'SIGN_IN') {
  15. location.replace("form.php");
  16. } else {
  17. alert(result);
  18. }
  19. });
  20.  
  21. });
  22.  
  23. <?
  24.  
  25. if(empty($_POST) === false) {
  26. $username = $_POST['username'];
  27. $password = $_POST['password'];
  28.  
  29.  
  30.  
  31. if(empty($_POST['username'])===true || empty($_POST['password'])===true) {
  32. echo 'You need to enter email and password';
  33. }else if($db->user_exists($username) === false) {
  34. echo 'We can't find the user. Have you registered?';
  35. }else {
  36.  
  37. $login = $db->login($username,$password);
  38. if($login===false) {
  39. echo 'Invalid password.';
  40.  
  41. }else{
  42. $_SESSION['user_id'] = $login;
  43. echo 'SIGN_IN';
  44. exit;
  45. }
  46. }
  47. }
  48.  
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement