Hi Vicki:
On Sun, Jun 23, 2002 at 09:30:39PM -0400, Vicki wrote:
> I have a shopping cart where users have added a list of documents for
> purchase. I want to allow users to remove documents from the cart before
> checkout. There are no quantities involved-- this is a "yes I want
> $docID" or "no I don't" situation.
The whole process starts with the form. If that's not made correctly, you
aren't going to get anywhere in your checkout. From your code, I have a
hunch that's where your first problem lies.
<form>
<input type="checkbox" name="item[124]" checked />
<input type="checkbox" name="item[268]" checked />
</form>
Now, the receiving script:
if ( !empty($_POST['save']) ) {
if ( empty($_POST['item']) OR !is_array($_POST['item']) ) {
echo "HEY! You haven't selected any items!";
} else {
while ( list($ID,) = each($_POST['item']) ) {
$cart[$ID];
}
}
}
This doesn't delete stuff from the cart. It just creates a new $cart
array containing only the things the person wants.
Note, I'm using empty() a lot to avoid "Warnings" in the event the
variables aren't set at all.
Also using the $_POST[] superglobal array, assuming you're using a
version of PHP >= 4.1.0.
Enjoy,
--Dan
--
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