Given a form and the task is to check form submitted successfully or not. Use the PHP program for the backend to check form submission and HTML and CSS to create the form as frontend.
if (!empty($_POST)) if (isset($_POST['submit']))
Use these two statements to check whether the form submitted successfully or not.
Note: To run this program use localhost server like WAMP or XAMPP.
Step 1: Create a simple form using HTML and CSS.
In this step, make an html form first to check whether it is submitted properly or not. So it is just basic programming to make a form using form tag. Use the action attribute to send the request to another PHP file. The method is used to GET the information or POST the information as entered in the form.
Step 2: Create PHP file for POST method
Use isset() method in PHP to test the form is submitted successfully or not. In the code, use isset() function to check $_POST[‘submit’] method. Remember in place of submit define the name of submit button. After clicking on submit button this action will work as POST method.
Final output on the localhost:
Without using separate PHP file: Without using a separate file, written an HTML code in which to specify the code for PHP action in script tag as we did in this demonstration. Both of these codes display the same output but their implementation is different.
Output on the localhost:
- How to clear form after submission in Angular 2?
- Design a form component which takes input from its user and displays a form
- PHP Full Form
- How to pass form variables from one page to other page in PHP ?
- How to get form data using POST method in PHP ?
- How to attach file with feedback form in PHP ?
- PHP Form Processing
- How to create a PHP form that submit to self ?
- Signup form using PHP and MySQL Database
- How to append data in JSON file through HTML form using PHP ?
- TCL Full Form
- How to create a responsive Modal Sign-Up form for a Website?
- HTML | Responsive Modal Login Form
- HTML | Design Form
- LFU Full Form
- HTML | DOM Input Submit form Property
- Probability of cutting a rope into three pieces such that the sides form a triangle
- How to turn on/off form autocompletion in HTML ?
- HTML | form Tag
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.