Fieldforwarder PHP script doesn't forward fields the second timearound

This is a discussion on Fieldforwarder PHP script doesn't forward fields the second timearound within the PHP Language forums, part of the PHP Programming Forums category; Hello all, I'm new to this newsgroup and have tried to search through the archives first, before posting this ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-18-2004
Marc de Winter
 
Posts: n/a
Default Fieldforwarder PHP script doesn't forward fields the second timearound

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 zend.com, 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:
http://www.zend.com/zend/spotlight/c...7.php#Heading9)

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"
id="italianchefsalad_junior">
<option value="0"<?php if ($italianchefsalad_junior==0) echo "selected";
?>>0</option>
<option value="1"<?php if ($italianchefsalad_junior==1) echo "selected";
?>>1</option>
<option value="2"<?php if ($italianchefsalad_junior==2) echo "selected";
?>>2</option>
</select>

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.

Sincerely,
Marc de Winter


Reply With Quote
  #2 (permalink)  
Old 10-18-2004
Website Managers, LLC
 
Posts: n/a
Default Re: Fieldforwarder PHP script doesn't forward fields the second time around


"Marc de Winter" <marc@cura.net> wrote in message
news:BD99463D.7215%marc@cura.net...
> 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 zend.com, 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:
> http://www.zend.com/zend/spotlight/c...7.php#Heading9)
>
> 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"
> id="italianchefsalad_junior">
> <option value="0"<?php if ($italianchefsalad_junior==0) echo "selected";
> ?>>0</option>
> <option value="1"<?php if ($italianchefsalad_junior==1) echo "selected";
> ?>>1</option>
> <option value="2"<?php if ($italianchefsalad_junior==2) echo "selected";
> ?>>2</option>
> </select>
>
> 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.
>
> Sincerely,
> Marc de Winter
>
>


It's been my experience that if you do not use a space between your option
and
<?php you will not get the desired results because it would be returned as
"0"selected
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
track
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
GET.

Jim Hutchinson
Website Managers, LLC
http://www.websitemanagers.net



Reply With Quote
  #3 (permalink)  
Old 10-19-2004
Ed Jones
 
Posts: n/a
Default Re: Fieldforwarder PHP script doesn't forward fields the second timearound

Marc de Winter wrote:

> 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:
> http://www.zend.com/zend/spotlight/c...7.php#Heading9)
>


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
(untested):

$_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:

pizza:
type: quattro formaggi
quantity: 1

pasta:
type: carbonara
quantity: 2

italianchefsalad_junior:
quantity: 1

Or you could find the quantity of italianchefsalad_junior at
$_SESSION['order']['italianchefsalad_junior']['quantity'].

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):

http://uk2.php.net/manual/en/function.session-start.php
http://uk2.php.net/manual/en/functio...n-register.php

Ed






Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:27 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0