PHP form - on submit stay on same page

后端 未结 9 918
醉梦人生
醉梦人生 2020-11-29 01:49

I have a PHP form that is located on file contact.html.

The form is processed from file processForm.php.

When a user fills out the

9条回答
  •  眼角桃花
    2020-11-29 01:56

    You have to use code similar to this:

    echo "
    "; if(isset($_POST['submit'])) // if form was submitted (if you came here with form data) { echo "Success"; } else // if form was not submitted (if you came here without form data) { echo "
    ...
    "; } echo "
    ";

    Code with if like this is typical for many pages, however this is very simplified.

    Normally, you have to validate some data in first "if" (check if form fields were not empty etc).

    Please visit www.thenewboston.org or phpacademy.org. There are very good PHP video tutorials, including forms.

提交回复
热议问题