Results 1 to 3 of 3

Thread: Passing variables from one page to another In PHP

  1. #1
    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.

  2. #2
    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'];

  3. #3
    Join Date
    May 2008
    Posts
    2,012

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

Similar Threads

  1. How variables are attacked with a custom HTML page in PHP?
    By Leoniee in forum Software Development
    Replies: 5
    Last Post: 05-03-2010, 01:36 AM
  2. Passing .iso to .exe
    By KADIN in forum Windows Software
    Replies: 4
    Last Post: 29-10-2009, 05:40 PM
  3. iText: page events and global variables
    By ASHER in forum Software Development
    Replies: 3
    Last Post: 24-10-2009, 08:52 PM
  4. Passing variables using iframes
    By Sayam in forum Software Development
    Replies: 3
    Last Post: 07-08-2009, 12:20 PM
  5. Passing variables in SQL Query
    By Braze in forum Software Development
    Replies: 2
    Last Post: 01-01-2009, 08:52 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,599,614.31289 seconds with 16 queries