maziagha Posted July 24, 2006 Share Posted July 24, 2006 Hi all!I have made/modified a PHP web-shop. Everything work fine except now i want to have a possibility to also choose Size on products i buy. The problem is that my script will not post the variables from the Form. Here how the code looks like for this part.<form method="post"><?phpif ($pd_size == 1) { ?><select name="sizer"> <option value="Small">Small</option> <option value="Medium">Medium</option> <option value="Large">Large</option></select><? }else if ($pd_size == 2) { ?><select name="sizer" > <option value="One-Size">onesize</option> <option value="XL">XL</option></select><?php } else if ($pd_size == 3) {?><select name="sizer"> <option value="S-M">S-M</option> <option value="M-L">M-L</option> <?php } ?></select><?php// if we still have this product in stock// show the 'Add to cart' button//if ($pd_qty > 0) {?><input type="submit" name="btnAddToCart" value="Add To Cart >" onClick="window.location.href='<?php echo $cart_url; ?>';" class="addToCartButton"></form>I have tried to put "Action" same as $cart_url but still it wont post the Sizes.Hope someone can help me. Quote Link to comment https://forums.phpfreaks.com/topic/15545-having-a-huge-form-problem/ Share on other sites More sharing options...
Chips Posted July 24, 2006 Share Posted July 24, 2006 This part:[quote author=maziagha link=topic=101742.msg402891#msg402891 date=1153778936][code]<form method="post">[/code][/quote]Why not make it have the action in there as usual? action="filename.php"[code]<form method="post" action="filename.php">[/code][quote author=maziagha link=topic=101742.msg402891#msg402891 date=1153778936][code]<input type="submit" name="btnAddToCart" value="Add To Cart >" onClick="window.location.href='<?php echo $cart_url; ?>';" class="addToCartButton"></form>[/code][/quote]I'd go with the action="value.php" instead, and you can add variables to this too:[code]<form name="formyform" method="post" action="index.php?id=<?php echo $cart_id?>">[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15545-having-a-huge-form-problem/#findComment-63156 Share on other sites More sharing options...
maziagha Posted July 24, 2006 Author Share Posted July 24, 2006 Ys i have tryid this, but it still wont do it.Instead of adding the product to cart, it just refreshes the page. Quote Link to comment https://forums.phpfreaks.com/topic/15545-having-a-huge-form-problem/#findComment-63167 Share on other sites More sharing options...
ryanlwh Posted July 24, 2006 Share Posted July 24, 2006 remove the onclick from the submit button. you dont want to "redirect" when it's clicked. Quote Link to comment https://forums.phpfreaks.com/topic/15545-having-a-huge-form-problem/#findComment-63169 Share on other sites More sharing options...
maziagha Posted July 24, 2006 Author Share Posted July 24, 2006 That does not work either! :-[ Quote Link to comment https://forums.phpfreaks.com/topic/15545-having-a-huge-form-problem/#findComment-63174 Share on other sites More sharing options...
ryanlwh Posted July 24, 2006 Share Posted July 24, 2006 the names of the select is "sizer"... should it be "sizes"? Quote Link to comment https://forums.phpfreaks.com/topic/15545-having-a-huge-form-problem/#findComment-63175 Share on other sites More sharing options...
maziagha Posted July 24, 2006 Author Share Posted July 24, 2006 Does't matter really!The $_REQUEST is calling "sizer" also Quote Link to comment https://forums.phpfreaks.com/topic/15545-having-a-huge-form-problem/#findComment-63176 Share on other sites More sharing options...
AndyB Posted July 25, 2006 Share Posted July 25, 2006 Simple stuff. The problem isn't with the form, it's with the form processing script and we haven't seen any of thaqt. Quote Link to comment https://forums.phpfreaks.com/topic/15545-having-a-huge-form-problem/#findComment-63188 Share on other sites More sharing options...
maziagha Posted July 25, 2006 Author Share Posted July 25, 2006 you can find the source code @ http://www.phpwebcommerce.com/php-mysql-shopping-cart-tutorial.php Quote Link to comment https://forums.phpfreaks.com/topic/15545-having-a-huge-form-problem/#findComment-63284 Share on other sites More sharing options...
maziagha Posted July 25, 2006 Author Share Posted July 25, 2006 Can anyone take a look at the codes and tell me what is wrong?The size part i have added my self so its not in the original code. Quote Link to comment https://forums.phpfreaks.com/topic/15545-having-a-huge-form-problem/#findComment-63308 Share on other sites More sharing options...
maziagha Posted July 25, 2006 Author Share Posted July 25, 2006 Please someone run the cart and help me! Quote Link to comment https://forums.phpfreaks.com/topic/15545-having-a-huge-form-problem/#findComment-63507 Share on other sites More sharing options...
ryanlwh Posted July 25, 2006 Share Posted July 25, 2006 can you post the part YOU added in the processing script? Quote Link to comment https://forums.phpfreaks.com/topic/15545-having-a-huge-form-problem/#findComment-63540 Share on other sites More sharing options...
maziagha Posted July 25, 2006 Author Share Posted July 25, 2006 form method="post"><select name="sizer"> <option value="Small">Small</option> <option value="Medium">Medium</option> <option value="Large">Large</option></select>This is what i added to the productdetail.php next to the descriptions part. But i can't get it posted so i can $_request it later on. Quote Link to comment https://forums.phpfreaks.com/topic/15545-having-a-huge-form-problem/#findComment-63549 Share on other sites More sharing options...
ryanlwh Posted July 25, 2006 Share Posted July 25, 2006 what about the processing part? have you done anything to save this into the database? Quote Link to comment https://forums.phpfreaks.com/topic/15545-having-a-huge-form-problem/#findComment-63559 Share on other sites More sharing options...
maziagha Posted July 25, 2006 Author Share Posted July 25, 2006 Well, since i don't get any posting of the form i cant even write it to database. I tryied but failed that also.Can you run the cart sript and check where it is bugging? Please please pretty please Quote Link to comment https://forums.phpfreaks.com/topic/15545-having-a-huge-form-problem/#findComment-63668 Share on other sites More sharing options...
ryanlwh Posted July 25, 2006 Share Posted July 25, 2006 i think it's the third if statement causing the problem. see my comment[code]<form method="post" action="<?php echo $cart_url ?>"><?phpif ($pd_size == 1) { ?><select name="sizer"> <option value="Small">Small</option> <option value="Medium">Medium</option> <option value="Large">Large</option></select><?php }else if ($pd_size == 2) { ?><select name="sizer" > <option value="One-Size">onesize</option> <option value="XL">XL</option></select><?php } else if ($pd_size == 3) {?><select name="sizer"> <option value="S-M">S-M</option> <option value="M-L">M-L</option> <?php } /*<---- This is supposed to go after </select>*/ ?></select><input type="submit" name="btnAddToCart" value="Add To Cart >" class="addToCartButton"></form>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15545-having-a-huge-form-problem/#findComment-63671 Share on other sites More sharing options...
maziagha Posted July 25, 2006 Author Share Posted July 25, 2006 nah never mind guys i solved the problem after sleeping on it and dreaming about it. ;DThe problem was that the add to cart URL was taken from an include file and that caused the problem.solved it buy making the page to a big script page.Thank you all for trying to help. Quote Link to comment https://forums.phpfreaks.com/topic/15545-having-a-huge-form-problem/#findComment-63685 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.