0

I have a very simple html form I have created for a contact page. I would like to know if it is possible to disable/avoid the page redirect that occurs when the form is sent but still allow for the form to be submitted (obviously). I essentially have almost zero knowledge of php at this time and I did not create the php aspect (see form action). Any help here is greatly appreciated.

<form action="" method="post" class="flex flex--column">
                        <input type="hidden" name="toEmail" value=""/>
                        <input type="text" name="name" placeholder="Name*" required><br>
                        <input type="email" name="email" placeholder="Email*" required><br>
                        <input type="text" name="phone" placeholder="Phone"><br>
                        <input type="text" name="message" placeholder="Message*" required><br>
                        <input type="submit" value="Submit" class="submit">
                    </form>
JSON_Derulo
  • 892
  • 2
  • 14
  • 39
  • 3
    Possible duplicate of [Prevent redirect after form is submitted](https://stackoverflow.com/questions/4038567/prevent-redirect-after-form-is-submitted), [How to submit html form without redirection?](https://stackoverflow.com/questions/25983603/how-to-submit-html-form-without-redirection), [What is AJAX and how does it work?](https://stackoverflow.com/questions/6009206/what-is-ajax-and-how-does-it-work), [How does AJAX work?](https://stackoverflow.com/questions/1510011/how-does-ajax-work), etc. - Please consider doing a bit more research before asking such a general question next time. – Tyler Roper Jul 10 '17 at 20:35

1 Answers1

1

Configure the form to post to a hidden iframe, as explained here: How do you post to an iframe?. The redirect will still happen, but it will be within the iframe and thus invisible to the user. It's a bit of a hack, and not the best way to do things, but it does work.

kmoser
  • 8,780
  • 3
  • 24
  • 40