Display "Thank you" bootstrap modal after php form action

Have just coded new single page website for small charity.

There are 3 forms on it that easch send emails to different charity officers, using PHP on the same page to determine which form posted the data, and this works fine…

Previous version redirected to a Thank you page after submission, but the customer would prefer it if a bootstrap modal “Thank You” was displayed instead to match the rest of the new website.,

The 3 email submissions work ok, but cannot work how to display the modal…after email has been sent.

Is this possible?

Many thanks

You just need to use the SHOW option to force it to show when a page is opened.
In this case something like this example page might work for you:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Example of Auto Loading Bootstrap Modal on Page Load</title>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://../bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
<script>
	$(document).ready(function(){
		$("#myModal").modal('show');
	});
</script>
</head>
<body>
<div id="myModal" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Subscribe our Newsletter</h5>
                <button type="button" class="close" data-dismiss="modal">&times;</button>
            </div>
            <div class="modal-body">
                <form>
                    <p>Thank you for subscribing to our mailing list.</p>
                    <button type="submit" class="btn btn-primary">Continue to page...</button>
                </form>
            </div>
        </div>
    </div>
</div>
</body>
</html>

You have to point the two links to Jquery and Bootstrap of course to get it to work.
Just a test page… Hope it helps…

Many thanks - will give it a try later when I am back home.

Unfortunately it doesn’t seem to work. The formi is processed by the PHP ok, the form contents clear but modal is not displayed.

Can you show us the code you have written ? From my experience, the code @ErnieAlex provided should work.

Sorry for delay in getting back, but had an arguement with a car, and lost!

Managed to get the code working ok so thanks for your help.

Well, hope you and our car did not get hurt very much… Hate auto accidents…

Sponsor our Newsletter | Privacy Policy | Terms of Service