Fieldforwarder PHP script doesn't forward fields the second timearound

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hello all,

I'm new to this newsgroup and have tried to search through the archives
first, before posting this question. I don't think it has been addressed
before. Also, this question is about a script I found on, and I
have also emailed the author of the script, unfortunately without any
replies sofar.

Here goes:

I am working on a website for pizza delivery. Through this website people
need to be able to order a pizza or pasta online.

The ordering proces will be a form with multiple pages. The visitor will be
guided through the menu in 5 steps. Step 1 being the pizzas, step 2 the
pastas, and so on.
On each page there is always the possibility to add an "side-order" to their
order. So, on the right is always the same list of side-orders.

I am using a script called fieldforwarder.php (see this page for the script:">

It works perfectly, however one challenge still remains and it has to do
with the side-order. I think it has something to do with the
fieldforwarder.php file.

The side-orders can be choosen during any step. So, if one chooses a side
order in step 1, it needs to remain chosen in the following steps. I have
this working, by using if statements. One pulldown menu in the side-order
menu looks like this:

<select name="italianchefsalad_junior" class="orderpulldown"
<option value="0"<?php if ($italianchefsalad_junior==0) echo "selected";
<option value="1"<?php if ($italianchefsalad_junior==1) echo "selected";
<option value="2"<?php if ($italianchefsalad_junior==2) echo "selected";

Although starting from step 2 the code looks this actually.
Well, it does work in a way that it shows me when i clicked something in the
side orders on the first page. However, when i try to choose something in
step 2 (or 3 or 4 or 5) it won't "remember" it.
I guess that the fieldforwarder.php file doesn't check for changes in
fields, it already has indexed? I'm not quite sure, because the code of the
file is a little bit too advanced for me.

Hopefully someone on here can help me out. I really hope so.

Marc de Winter

Re: Fieldforwarder PHP script doesn't forward fields the second time around

Quoted text here. Click to load it
Quoted text here. Click to load it

It's been my experience that if you do not use a space between your option
<?php  you will not get the desired results because it would be returned as
instead of "0" selected. So that's your first step.

<option value="0" <?php if ($italianchefsalad_junior==0) echo "selected";

The second step is on each page either use sessions $_SESSION["item"] to
the items, or use $_POST["item"] $_GET["item"] or $_REQUEST["item"] to track
each item in the order. The REQUEST option does not care of it's a POST or

Jim Hutchinson
Website Managers, LLC

Re: Fieldforwarder PHP script doesn't forward fields the second timearound

Marc de Winter wrote:

Quoted text here. Click to load it

I don't have experience of the Zend script you're referring to, but this
sounds to me like a classic situation for an array session variable.

What you're describing is a shopping cart, really. I would suggest
registering a session variable called somthing like $order, and adding
things to it. It'll be an array (arbitrarily deep), so the order
information could be stored in that. For example the array might contain

$_SESSION['order'] = array(
    pizza => array (type => 'quattro formaggi', quantity => 1),
    pasta => array (item => 'carbonara', quantity => 2),
    italianchefsalad_junior => array (quantity => 1)

etc, etc.

That way, you could always refer to the session array $order to find out
what was on the buyers list (untested):

foreach ($_SESSION['order'] as $dish => $details) {
    echo $dish.":<br>";
    foreach ($details as $detail => $information) {
        echo $detail.": ".$information."<br>";
    echo "<br>";

this will give you something like:

type: quattro formaggi
quantity: 1

type: carbonara
quantity: 2

quantity: 1

Or you could find the quantity of italianchefsalad_junior at

Clearly the data structure needs to be carefully thought through, and my
suggested one is probably totally inappropriate for your application,
but you might get the idea.

For more info on PHP sessions and session variables, the PHP website is
essential reading (UK mirrors given):



Site Timeline