Send Data from One Page to Another Page in PHP
Advertisements
Transfer Data from One Page to Another Page in PHP
To transfer data from one web page to another webpage we need Html form and using action="" we transfer form data on another page.
Using $_POST['field_name'] we receive form data on another page in PHP if method is post in case of get method use $_GET['field_name'];.
index.html
Html page
<form action="display.php" method="post" id="nameform"> First Name: <input type="text" name="fname"></br> Last Name: <input type="text" name="lname"></br> <button type="submit" form="nameform" value="submit">Submit</button> <button type="reset" value="Reset">Reset</button> </form>
display.php
Receive form data on other page
<?php $first_name = $_POST['fname']; $last_name = $_POST['lname']; echo $first_name; echo $last_name; ?>
When you fill html form all data will be transfer from index.php to display.php
Google Advertisment