Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Staying on page after submitting

Tags:

html

jquery

php

just a question --

How do i actually submit a form and still stay on the same page whilst the script is being executed?

I have a simple form that goes like this:

<form action="process.php" method="post" id="form">
    <label for="name">Name</label>
    <input type="text" name="name" id="name" required="required" />
    <label for="email">Email</label>
    <input type="email" name="email" id="email" required="required" />
    <label for="subject">Subject</label>
    <input type="text" name="subject" id="subject" required="required" />
    <label for="message">Message</label>
    <input type="text" name="message" id="message" required="required" />
    <input type="submit" id="button" value="Submit"/>
</form>

But everytime i submit the form it just goes to process.php. I don't want that, i want it to stay on the same page, maybe even have a jquery popup saying "thank you" or something.

How do i actually stay on the same page whilst the script is being run?

like image 498
Kyle Yeo Avatar asked Oct 22 '25 08:10

Kyle Yeo


1 Answers

  1. Put your form processing logic on the same page as the form
  2. Use Ajax
  3. Redirect back to that page when process.php is done processing the form
like image 134
John Conde Avatar answered Oct 24 '25 22:10

John Conde