Hey Vicki:

On Wed, Jun 26, 2002 at 11:01:31AM -0400, Vicki wrote:

> I'm checking the cart structure by printing the following code inserted
> right after the "if($save);"
> line (is this the best way to check on the contents of an array?)
> while (list($key,$value) = each($cart)) 
>    {
>       print "Cart = $key: $value<BR>";
>    }
> This returns "article ID number (an integer) : 1" when new
> and "article ID : yes" after the save button has been clicked. 

Excellent debugging idea, Vicki!  But, you're not showing us what was
litterally produced by that output.  Please copy and paste _exactly_ what
comes from that.

Also, I want to make sure I understand how this process is working.  
Correct me where I'm wrong.  We're talking about a checkout page, to which
people come after they've browsed around and selected what they want. This
page lists the things the person wants and has a box folks can un-check if
they don't want a given item.  Then, the user submits the final request
back to this same page.  But, since the process has been submitted for
final processing, the "if ($save)" statement evaluates to true...

Man, you know what, I'm looking at this cart script and I really don't
like how it works...  I'd put everything about an item into a
multidimensional cart array, as I mentioned yesterday, where the article
ID is the first key and then the "field" (such as 'quantity,' 'wordcount,'
'cost,' etc) is the second key...  plus, the code is really ugly...  and
the code looks easily susceptible to url tweaking vulnerabilities, like
what crazyness would happen if someone sets both the $new and $save
variables, DUH...  so, if anyone asks for recommendations of a good
programming book, keep them away from Welling and Thomson...  but,
anyway, where was I...

the final processing happens when the "if ($save)" statement comes back as 

Have I got it straight, here?

If so, please put your debugging loop at the top and bottom of the
confirmation/submission script (so we can see what the raw and final data
are).  Then, put two or three items in the cart, and go to the
confirmation page.  Show us the output of the loops, PLUS the HTML form
(not your code that renders the HTML) that comes back to your browser when
you're looking at the confirmation page.  THEN, go and submit the page and
transmit the results of the loops.

> else  
>    $cart[$artID] = $$artID;
> I thought it was odd too, and since this is acquired code, I can't 
> explain it. I assumed that it 
> just resets the artID to its original value.

Now that I think about it, that line makes (some kind of) sense.  It's 
assigning the value of your checkbox "true," to the cart array element 
numbered $artID.  Silly, but, hey, this whole program is.


               PHP classes that make web design easier
        SQL Solution  |   Layout Solution   |  Form Solution
    sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY     v: 718-854-0335     f: 718-854-0409

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to