Android Tutorial , Programming Tutorial, Php Tutorial, Learn Android, HTML Tutorial, Coding , Java Tutorial, GTU Programs, Learning Programming

Friday 7 October 2016

Passing variable from one PHP file to another PHP file

In this example, we are trying to pass variable from one page to another page using php. Here we are creating two php file for running this example. The example below display a simple php form with two input fields and submit button.

For passing variable from one page to another page , we are using POST method in this example. Let's see the example.


File Name : demo.php


  • When You want to sending form data from one page to another page , this time POST method is used.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
<!DOCTYPE HTML>
<html>  
<body>

<form action="welcome.php" method="post">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>

</body>
</html>


File Name : welcome.php



1
2
3
4
5
6
7
<?php
$name=$_POST["name"];
$email=$_POST["email"];
echo "Welcome ".$name;
echo "<br/>";
echo "Your Email Id is : ".$email;
?>


Output :

passing value from one page to another page in php


0 comments:

Post a Comment

Like us on Facebook

Site Visitor

Powered by Blogger.