Thursday, March 22, 2012

Data transfer from one file to another using PHP

For transferring the information between two files, create the two files with the designs you want.
Go to notepad or notepad++ (recommended) and write the following code in it....


<html>
<head>
    <title></title>
</head>
<body>
    <form name="f1" method="POST" action="2.php
" >
    Name <br />
    <input type = "txt" name = "t1" />
    <br /><br />
    E-mail ID<br />
    <input type = "txt" name = "t2" />
    <br /><br />
    Contact<br />
    <input type = "txt" name = "t3" />
    <br /><br />
    Password<br />
    <input type = "pass" name = "p1" />
    <br /><br />
    <input type = "submit" value = "OK" />
    </form>

</body>
</html>


Now save this file as 1.php
Create a new file in notepad or notepad++ and copy the following code in it :-

<html>
<head>
    <title></title>
</head>
<body>
    <form name="f1">
    Name <br />
    <input type = "txt" name = "t1" value="<?php echo $_POST['t1']?>"/>
    <br /><br />
    E-mail ID<br />
    <input type = "txt" name = "t2" value="<?php echo $_POST['t2']?>"/>
    <br /><br />
    Contact<br />
    <input type = "txt" name = "t3" value="<?php echo $_POST['t3']?>" />
    <br /><br />
    Password<br />
    <input type = "pass" name = "p1" value="<?php echo $_POST['p1']?>"/>
    <br /><br />
   
    </form>

</body>
</html>

Now save this file as 2.php and see the output as desired.
Note :- The file name specified in the first code must be same as that of the second file.

No comments:

Post a Comment