GET variables submitted by form
| From: | Harold | Date: | Tue, 07 Mar 2000 11:12:34 +0000 |
| Subject: | GET variables submitted by form | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-11665@lists.php.net to get a copy of this message | ||
i am experiencing strange behaviour problems with PHP when forms are
submitted as GET.. i am using apache 1.3.12 / php4b4(pl1)..
for the following examples, the session customer_id is not set..
i have a form which is submitted in the following manner
shopping_cart.php?SID=<the sid>&products_id=10&action=add_product
everytime this is submitted with cookies disabled, it only goes through the
else statement of line 13-15, and gives me a new session id..
if the form is submitted in the following manner (also with cookies
disabled)
shopping_cart.php?action=add_product&products_id=10&SID=<the sid>
it works fine.. the $nonsess_cart is returned properly with an example of
1:1|4:1|2:2 (product id:product qty).. i keep the same session id too (which
is meant to be normal ;))
shopping_cart.php:
01: if ($HTTP_GET_VARS["action"]) {
02: if ($HTTP_GET_VARS["action"] == "add_product") {
03: if (session_is_registered("customer_id")) {
04:
05: .. do some stuff..
06:
07: header("Location: shopping_cart.php?" . SID);
08: } else {
09: if (session_is_registered("nonsess_cart")) {
10:
11: .. do some stuff.. -> basically $nonsess_cart.='|' .
$HTTP_GET_VARS["products_id"] . ':1';
12:
13: } else {
14: $nonsess_cart = $HTTP_GET_VARS["products_id"] . ':1';
15: }
16: session_register("nonsess_cart");
17: header("Location: shopping_cart.php?" . SID);
18: }
19: } elseif ($HTT..
line 11 checks to see if the product id exists in the 'exploded' array, and
if yes, it increments the product quantity.. if not, it appends <product
id>:1
when cookies are enabled, either way the form is submitted it works fine..
is this a problem with the way php handles GET variables? or is there a
problem with the above snippet?
thanks for your time
harald