Search code examples
phphtmlpopupcontactscontact-form

How to make a PHP Error message popup instead of new page?


Currently on my website I have a form in which once it is submitted, you're taken to a blank screen with the appreciation message.

Instead of moving to a new page, I wish to keep my users on the same page. How might I go about creating a popup and keeping the user within the same page?


Solution

  • You can use javascript validation or HTML5. If you don't want these ways you can just open a popup window and set your form's target to it. Like this :

    <form method="post" action="anything.php" onsubmit="window.open('','my_form_target', 'width=300,height=200', true); this.target='my_form_target';" >
    ...