PHP Loops
We pass data from one page to another using form or url link. We will see how we can submit/pass data from one page to another.
Example:
< !DOCTYPE html>
< html>
< head>
< title>PHP Form example< /title>
< /head>
< body>
< form name="frm" action="" method="post">
< p>First Name :
< input name="f_name" type="text" id="f_name" />
< /p>
< p><Last Name :
< input name="l_name" type="text" id="l_name" />
< /p>
< p>
< input type="submit" name="Submit" value="Submit" />
< /p>
< /form>
< /body>
< /html>
Output:
If you look at above example carefully, there are few important things in form section.
If you want to catch data in another page then the action will be like this action=”submitted_form.php”
There are primarily two methods:
Example get method:
Example:
If you submit the data using GET method, the data will be passed through URL like this.
http://localhost/php-book/form.php?f_name=Rajesh&l_name=Kumar&Submit=Submit
To start with, I will show you example of GET method. In this section we will see how we can submit the data using GET method and how we can catch the submitted data.
Example:
First Name :
Last Name :