I have a login script and I am using bootstrap modal for login form. It works fine except i am unable to catch the value of a php var, this is sent as a response when the form is submitted.
http://localhost/clock/index.php?f=4
I would like to be able to catch value of f4 in my modal which I am not able to. how can i do this ?
Edited:
Javascript/Jquery code to send ajax request
$(document).ready(function(){
$('#csignin').click(function(){
$("#myModal-signin").modal('show');
});
$('#csignup').click(function(){
$("#myModal-signup").modal('show');
});
$('#loginForm').on("submit", function (e) {
e.preventDefault();
//alert('submitting');
$.ajax({
type: "POST",
url: 'usr/login_process.php',
data: $('#loginForm').serialize(),
dataType: 'text',
timeout: 5000,
success: function(data) {
//success msg
//alert(data);
$(".signin-msg").html("<?php
if (isset($_SESSION['f'])) {
switch ($_SESSION['f']) {
default: break;
case 0:
echo LOGIN_NOT_ACTIVE_USER;
break;
case 1:
echo LOGIN_USER_BLOCKED;
break;
case 2:
echo LOGIN_PASSWORDS_NOT_MATCHED;
break;
case 3:
echo LOGIN_NO_TRIES;
break;
case 4:
echo LOGIN_USER_INFO_MISSING;
break;
case 5:
echo LOGIN_NOT_ACTIVE_ADMIN;
break;
}
}
?>").css("color", "red");
}
});
});
});
this is PHP code sends response to ajax call (http://localhost/clock/index.php?f=4)
if (isset($_POST['process'])) {
// Try to login the user
if ($qls->User->login_user()) {
$qls->redirect($qls->config['login_redirect']);
}
else {
$_SESSION['f']=$qls->User->login_error;
$qls->redirect('../index.php?f=' . $qls->User->login_error);
}
}
else {
$qls->redirect('../index.php');
}
I would like to catch the var f sent by php in the modal box to show the appropriate error message.
I would appreciate any help.