Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .on('success.form.fv', function(e) {
- // Prevent form submission
- e.preventDefault();
- // Get the form instance
- var $form = $(e.target);
- // Get the BootstrapValidator instance
- var fv = $form.data('formValidator');
- // Use Ajax to submit form data
- $.post($form.attr('action'), $form.serialize(), function(result) {
- console.log(result);
- if(result === 'SIGN_IN') {
- location.replace("form.php");
- } else {
- alert(result);
- }
- });
- });
- <?
- if(empty($_POST) === false) {
- $username = $_POST['username'];
- $password = $_POST['password'];
- if(empty($_POST['username'])===true || empty($_POST['password'])===true) {
- echo 'You need to enter email and password';
- }else if($db->user_exists($username) === false) {
- echo 'We can't find the user. Have you registered?';
- }else {
- $login = $db->login($username,$password);
- if($login===false) {
- echo 'Invalid password.';
- }else{
- $_SESSION['user_id'] = $login;
- echo 'SIGN_IN';
- exit;
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement