One way of approaching this is by "catching the click event", preventing the default action and taking it from there.
<script>
$('button[type="submit"]').click(function(event){
event.preventDefault();
$.ajax({
success: function(data, status, xhr) {
$('#modal-div').modal('close');
},
url: ...,
type: ...,
})
})
You need to make an AJAX request to a PHP script that validates your credentials from MySQL or whatever. That script should return a HTTP header 200 if login went well, and 401 otherwise. This HTTP request should also return a body (not <body>
) with "OK" or similar so that it's easy to check that everything went fine in the success-handler of the AJAX request. The success-handler (callback) is also the proper place to close the modal.
Research whatever you do not understand in my answer. Read introductory material to the topics below. When you have a sufficient understanding of these concepts, update your question with code that you have written. Explain why you think that code should work, and outline your ideas about why you think it doesn't work. That way, you will get help on this site.
- HTTP status codes
- PHP HTTP header
- PHP HTTP response
- why is javascript asynchronous
- success callback
- jQuery ajax request