1<form action="/action.php">
2 <label for="fname">First name:</label><br>
3 <input type="text" id="fname" value="Mike"><br><br>
4 <label for="lname">Last name:</label><br>
5 <input type="text" id="lname" value="Walker"><br><br>
6 <input type="submit" value="Submit">
7</form>
1<form method="POST" action="INSERT WHERE YOU'RE SENDING THE DATA TO HERE">
2 <input type="text" name="INSERT DATA KEY NAME HERE"> <!-- You don't have to have this line -->
3</form>
1 <label for="fname">First name:</label><br>
2 <input type="text" id="fname" name="fname"><br>
1<form action="/action.php">
2 <label for="fname">First name:</label><br>
3 <input type="text" id="fname" value="Mike"><br><br>
4 <label for="lname">Last name:</label><br>
5 <input type="text" id="lname" value="Walker"><br><br>
6 <input type="submit" value="Submit">
7</form>
8
9Html By Duco Defiant Dogfish on Feb 11 2020
10<form action="/action_page.php">
11 First name:<br>
12 <input type="text" name="firstname" value="Mickey"><br>
13
14 Last name:<br>
15 <input type="text" name="lastname" value="Mouse"><br><br>
16
17 <input type="submit" value="Submit">
18</form>
1 // Check if the form is submitted
2if ( isset( $_POST['submit'] ) ) {
3
4// retrieve the form data by using the element's name attributes value as key
5
6echo '<h2>form data retrieved by using the $_REQUEST variable<h2/>'
7
8$firstname = $_REQUEST['firstname'];
9$lastname = $_REQUEST['lastname'];
10
11// display the results
12echo 'Your name is ' . $lastname .' ' . $firstname;
13
14// check if the post method is used to submit the form
15
16if ( filter_has_var( INPUT_POST, 'submit' ) ) {
17
18echo '<h2>form data retrieved by using $_POST variable<h2/>'
19
20$firstname = $_POST['firstname'];
21$lastname = $_POST['lastname'];
22
23// display the results
24echo 'Your name is ' . $lastname .' ' . $firstname;
25}
26
27// check if the get method is used to submit the form
28
29if ( filter_has_var( INPUT_GET, 'submit' ) ) {
30
31echo '<h2>form data retrieved by using $_GET variable<h2/>'
32
33$firstname = $_GET['firstname'];
34$lastname = $_GET['lastname'];
35}
36
37// display the results
38echo 'Your name is ' . $lastname .' ' . $firstname;
39exit;
40}
41