Hi all,
I am developing new application using PHP,
I am trying to pass the variables in a form from one page to another. but, I don't know how to do that.
Can anybody please help me. :help:
Printable View
Hi all,
I am developing new application using PHP,
I am trying to pass the variables in a form from one page to another. but, I don't know how to do that.
Can anybody please help me. :help:
You can check this code.
For Page1
For Page2Code:<form name="form1" action="page2.php" method="post">
<input type="text" name="var1" value="">
<input type="submit" name="submit" value="submit">
</form>
Code:$variable_from_page1 = $_POST['var1'];
Here is a simple example of how to pass a PHP variable from one page to another with the post method
Code:<form method="post" action="array_script.php">
0.<br/>
<input type="text" name="first_name0"/><br/><br/>
1.<br/>
<input type="text" name="first_name1"/><br/><br/>
2.<br/>
<input type="text" name="first_name2"/><br/><br/>
3.<br/>
<input type="text" name="first_name3"/><br/><br/>
4.<br/>
<input type="text" name="first_name4"/><br/><br/>
<input type="submit" name="submit"/> </form>
Values sent to the server corresponding to "first_name0" through " first_name4" will each occupy its' own space in the $_POST super global array. Now, let's write a piece of code on how to get those variables from the server to my script "array_script.php."
Code:<?php
$first_name0 = $_POST['first_name0'];
$first_name1 = $_POST['first_name1'];
$first_name2 = $_POST['first_name2'];
$first_name3 = $_POST['first_name3'];
$first_name4 = $_POST['first_name4'];
?>