I’ve created a jquery dialog modal box for logging into my website:
$('#login').dialog({
modal: true,
position: 'center',
autoOpen: false,
title: 'Login',
height: '750px',
width: '300px',
zIndex: 9999,
closeOnEscape: false,
buttons: {
'Login': function() {
$(this).dialog('close');
$('#mask').hide();
Login();
},
'Cancel': function() {
$(this).dialog('close');
$('#mask').hide();
}
}
});
I’ve created a php function called Login() in a separate php file, is it possible for me to call that php function when they click on the Login button? If not, how can I get that dialog’s Login box to use php to attempt logging in.
Update: Do this over an SSL connection for true security
You simply need to make a behind-the-scenes request using AJAX. For example,
$.postin jQuery.$.post()it to the/login.phpfile that contains the login code$.postwindow.location = '/nextpage.php'or display an error message.As per http://docs.jquery.com/Ajax/jQuery.post, you have 4 arguments to
$.post:so that
and in the file
login.php, you would: