Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 24-01-2009
Member
 
Join Date: Dec 2008
Posts: 19
Passing variables from one page to another In PHP

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.
Reply With Quote
  #2  
Old 24-01-2009
Member
 
Join Date: Apr 2008
Posts: 1,948
Re: Passing variables from one page to another In PHP

You can check this code.

For Page1

Code:
<form name="form1" action="page2.php" method="post">
<input type="text" name="var1" value="">
<input type="submit" name="submit" value="submit">
</form>
For Page2

Code:
$variable_from_page1 = $_POST['var1'];
Reply With Quote
  #3  
Old 24-01-2009
Member
 
Join Date: May 2008
Posts: 2,008
Re: Passing variables from one page to another In PHP

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'];



?>
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Passing variables from one page to another In PHP"
Thread Thread Starter Forum Replies Last Post
How variables are attacked with a custom HTML page in PHP? Leoniee Software Development 5 05-03-2010 01:36 AM
Passing .iso to .exe KADIN Windows Software 4 29-10-2009 05:40 PM
iText: page events and global variables ASHER Software Development 3 24-10-2009 08:52 PM
Passing variables using iframes Sayam Software Development 3 07-08-2009 12:20 PM
Passing variables in SQL Query Braze Software Development 2 01-01-2009 08:52 PM


All times are GMT +5.5. The time now is 01:41 AM.