Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: passing values

  1. #1
    Regular Coder
    Join Date
    Feb 2004
    Location
    Malaysia
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts

    passing values

    hi all,
    ok this might be a simple question but i still am not really sure. ok here it goes, i have 4 forms. lets name is pg1.php, pg2.php,pg3.php,pg4.php.
    pg1.php is where all the users fill up their particulars and then this will go to pg2.php. in pg2.php, the will choose their options like designs or music or whatever. then pg2.php will go to pg3.php to make their final selections of what they have selected from pg2.php. then this leads to the last page, pg4.php and this page is where all the data that the user has picked from pg1.php to pg3.php will go inside.
    now the question. from pg1.php, how do i pass the values that the user has filled in and carry it till the last page(pg4.php) and insert it into the database? understand what i am trying to do here? i mean...to be exact, how do i pass all the values that the user has chosen/filled from pg1.php to pg3.php and insert it all into the database in pg4.php?
    pls help..much appreaciated.thanking u in advance.
    Warm Regards,
    Mivec

  • #2
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you make use of hidden form values, this can be done quite easily. Example of pg1.php:

    Code:
    <form action="pg2.php" method="post">
    Name: <input type="text" name="Name" />
    Email: <input type="text" name="Email" />
    <input type="submit" value="Submit" />
    </form>
    Then for pg2.php, use some PHP:

    PHP Code:
    <form action="pg3.php" method="post">
    <input type="[b]hidden[/b]" name="Name" value="<?php echo $_POST['Name']; ?>" />
    <input type="[b]hidden[/b]" name="Email" value="<?php echo $_POST['Email']; ?>" />
    Country: <input type="text" name="Country" />
    ..... And so on
    <input type="submit" value="Submit" />
    </form>
    Notice how I set the action to "post", so I can access the $_POST[] array on subsequent pages. The information that pg2.php would send in the example above is:

    $_POST['Name'] = value of "Name" input
    $_POST['Email'] = value of "Email" input
    $_POST['Country'] = value of "Country" input

  • #3
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Or you can pass them by sessions

  • #4
    Regular Coder
    Join Date
    Feb 2004
    Location
    Malaysia
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks for the reply so quick.. but what u told me is what i know. the thing is...how do u carry those values from pg1.php right up to pg4.php?do i have to keep using :

    PHP Code:
    <input type="hidden" name="Name" value="<?php echo $_POST['Name']; ?>" />
    till the end?this is what i meant. i know how to pass values between 2-3 pages...how about 4 and so on?do i have to put

    PHP Code:
    <input type="hidden" name="Name" value="<?php echo $_POST['Name']; ?>" />
    in pg2.php, pg3.php and pg4.php? or just only one time?which is what u demonstrate?pls advice
    Warm Regards,
    Mivec

  • #5
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You would need to put that on all the pages you wanted the information to be passed from.

    Or you could go with nightfire and use sessions.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •