samjslater Posted November 26, 2012 Share Posted November 26, 2012 I've spent nearly 5 hours trying to word out why the form won't pass the correct price to the shopping cart after seeing if the Discount code (yes it's SANTA101) is correct. I can make all the correct calculations happen on the first page, but it won't send the right info to the shopping cart. i'm tired, and my client is pissed. Any help and i'll send you a mince pie. Hell, i'll bake Santa. Thanks in advance. Sam p.s. I've deleted anything long and unnecessary. <?php if($_GET['product'] == 1){ $productNAME = "Limited Edition"; $productDESCRIPTION = "Self Assembly Gifts: Limited edition bauble in display box."; $productPRICE = "14.99"; $productDISCOUNT = "10.99"; } if($_GET['product'] == 2){ $productNAME = "Standard Edition"; $productDESCRIPTION = "Self Assembly Gifts: Standard edition bauble."; $productPRICE = "6.99"; $productDISCOUNT = "5.99"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <link rel="stylesheet" type="text/css" href="lib/jquery.ad-gallery.css" /> <body text="#990000" link="#B78D2E" vlink="#634C17"> <div id="header"> <div class="content"> <h1> </h1> </div> </div> </div> <!-- end header --> <div id="wrapper"> <div id="outer1"> <div class="content"> <div id="container"> <div id="content"> <div class="section-header a"> <div class="section-title"> <h5>GIFTS</h5> </div> </div> <div class="section"> <div class="bullet"> <div class="bullet-number top-pad"> <h1>1</h1> </div> <div class="project-blockr"></div> <div class="product-block"> <div class="product-block"> <a href="?product=1"> <h4>Christmas Bauble</h4> </a> <h4>(limited edition)</h4> </div> </div> <div class="price-block">RRP: <strong>£14.99</strong> </div> </div> <div class="bullet"> <div class="bullet-number top-pad"> <h1>2</h1> </div> <div class="project-blockr"></div> <div class="product-block"> <div class="product-block"> <a href="?product=2"> <h4>Christmas Bauble</h4> </a> <h4>(standard edition)</h4> </div> </div> <div class="price-block">RRP: <strong>£14.99</strong> </div> </div> <div class="spacer"> </div> <div class="about"> Here at SAgifts we believe that all ages should enjoy trying their hand and brain at part of the making process. We gift design that engages you with the joys of assembling and learning as you do. </div> <div class="about"> Our first gift we are sharing is a christmas bauble. </div> <div class="about"> Give as a gift to a friend, a family member, or why not treat yourself to an innovative, festive and fun activity to light up christmas. </div> </div> </div> </div> </div> <!-- end content --> </div> <div id="outer2"> <div class="content"> <div id="container"> <div id="content"> <div class="section-header b"> <div class="section-title"> <h5>GALLERY</h5> </div> </div> <!------- Starter image ------------> <? if(!isset($_GET['product'])){ ?> <img src="images/layout/center.png" title="Rob Sharple's Ball Ball.jpg" alt="A view in hand.jpg" class="image0" /> <? } ?> <!-------- Starter Image End ---------> <? if ($_GET['product'] == 1){ ?> <div id="gallery" class="ad-gallery"> <div class="ad-image-wrapper"> </div> <div class="ad-controls"> </div> <div class="ad-nav"> <div class="ad-thumbs"> </div> </div> </div> <? } ?> <? if ($_GET['product'] == 2){ ?> <div id="gallery" class="ad-gallery"> <div class="ad-image-wrapper"> </div> <div class="ad-controls"> </div> <div class="ad-nav"> <div class="ad-thumbs"> </div> </div> </div> <? } ?> </div> </div> </div> <!-- end content --> </div> <!-- end outer2 --> <div id="outer3"> <div class="content"> <div id="container"> <div id="content"> <div class="section-header c"> <div class="section-title"> <h5>CHRISTMAS LIST</h5> </div> </div> <form action="http://ww7.aitsafe.com/cf/add.cfm" method="post"> <input name="userid" type="hidden" value="94285118" /> <input name="product" type="hidden" value="<? echo $productNAME; ?>" /> <input name="qty" type="hidden" value="<? echo $qty; ?>" /> <input type="hidden" name="gift_amount" value="<? if($_GET['promo'] == "SANTA101"){ echo "4"; } else { echo "0"; } ?>" /> <input name="price" type="hidden" value="<? if($_GET['promo'] = "SANTA101"){ echo $productDISCOUNT; } else { echo $productPRICE; } ?>" /> <input name="return" type="hidden" value="http://selfassemblygifts.com/shop.php" /> <div class="section"> <div class="bullet"> <div class="bullet-number"> <h1>1</h1> </div> <h4> Product </h4> <div class="description-box"> <? if(isset($_GET['product'])){ echo $productDESCRIPTION; } else { echo "Start at A: GIFTS"; } ?> </div> </div> <div class="bullet"> <div class="bullet-number"> <h1>2</h1> </div> <h4>Quantity</h4> <p> <div class="bullet-cart-space"> <h1> </h1> </div> <input name="qty" type="text" size="5" maxlength="3" /> </p> </div> <div class="bullet"> <div class="bullet-number"> <h1>3</h1> </div> <h4>Got a promo code?</h4> <p> <div class="bullet-cart-space"> <h1> </h1> </div> <input name="promo" type="text" size="10" maxlength="10" /> </p> <div class="bullet"> <div class="bullet-number"> <h1>4</h1> </div> <div class="bullet-cart-space"> <h1> </h1> </div> <input type="image" name="button" src="images/layout/cart.gif" style="margin-left: -50px;" /> </div> </div> </form> </div> </div> </div> </div> <!-- end content --> <!-- end outer2 --> <!-- end #wrapper --> <div id="footer-suround"> <div id="footer"> <div id="about"> <div class="content"> <div class="footer-picture"> <img src="images/layout/logo.gif" width="98" height="97" alt="logo" /> </div> <div class="footer-content"> <div class="footer-content-text"> <p><img src="images/layout/email.gif" width="240" height="28" alt="email: overhere@selfassemblygifts.co.uk" /><br /> <img src="images/layout/twitter.gif" width="141" height="28" alt="twitter: @SAgifts / #SAgifts" /></p> </p> </div> </div> </div> <p> </p> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> </form> </div> </div> <!-- end footer --> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/271212-simple-answer-im-a-tard-form-submission-problem/ Share on other sites More sharing options...
Jessica Posted November 26, 2012 Share Posted November 26, 2012 This is still WAAY too much code. Stop using short tags. That's probably your problem. Quote Link to comment https://forums.phpfreaks.com/topic/271212-simple-answer-im-a-tard-form-submission-problem/#findComment-1395324 Share on other sites More sharing options...
samjslater Posted November 26, 2012 Author Share Posted November 26, 2012 What do you mean by short tags? as in "<?" Quote Link to comment https://forums.phpfreaks.com/topic/271212-simple-answer-im-a-tard-form-submission-problem/#findComment-1395325 Share on other sites More sharing options...
Jessica Posted November 26, 2012 Share Posted November 26, 2012 Yes. Quote Link to comment https://forums.phpfreaks.com/topic/271212-simple-answer-im-a-tard-form-submission-problem/#findComment-1395328 Share on other sites More sharing options...
Jessica Posted November 26, 2012 Share Posted November 26, 2012 Oh, also your form is method=POST and you're checking $_GET. Quote Link to comment https://forums.phpfreaks.com/topic/271212-simple-answer-im-a-tard-form-submission-problem/#findComment-1395329 Share on other sites More sharing options...
samjslater Posted November 26, 2012 Author Share Posted November 26, 2012 ok, this is the functional bits (assuming the 'productID' var is set in the link) <?php if($_GET['product'] == 1){ $productNAME = "Limited Edition"; $productDESCRIPTION = "Self Assembly Gifts: Limited edition bauble in display box."; $productPRICE = "14.99"; $productDISCOUNT = "10.99"; } if($_GET['product'] == 2){ $productNAME = "Standard Edition"; $productDESCRIPTION = "Self Assembly Gifts: Standard edition bauble."; $productPRICE = "6.99"; $productDISCOUNT = "5.99"; } ?> <form action="http://ww7.aitsafe.com/cf/add.cfm" method="post"> <input name="userid" type="hidden" value="94285118" /> <input name="product" type="hidden" value="<? echo $productNAME; ?>" /> <input name="qty" type="hidden" value="<? echo $qty; ?>" /> <input type="hidden" name="gift_amount" value="<? if($_GET['promo'] == "SANTA101"){ echo "4"; } else { echo "0"; } ?>" /> <input name="price" type="hidden" value="<? if($_GET['promo'] = "SANTA101"){ echo $productDISCOUNT; } else { echo $productPRICE; } ?>" /> <input name="return" type="hidden" value="http://selfassemblygifts.com/shop.php" /> <? if(isset($_GET['product'])){ echo $productDESCRIPTION; } else { echo "Start at A: GIFTS"; } ?> <input name="qty" type="text" size="5" maxlength="3" /> <input name="promo" type="text" size="10" maxlength="10" /> <input type="image" name="button" src="images/layout/cart.gif" style="margin-left: -50px;" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/271212-simple-answer-im-a-tard-form-submission-problem/#findComment-1395330 Share on other sites More sharing options...
Jessica Posted November 26, 2012 Share Posted November 26, 2012 (edited) So your URL looks like page.php?product=1&promo=SANTA101 right? What does the source of the page look like when you view it in the browser? Edited November 26, 2012 by Jessica Quote Link to comment https://forums.phpfreaks.com/topic/271212-simple-answer-im-a-tard-form-submission-problem/#findComment-1395331 Share on other sites More sharing options...
samjslater Posted November 26, 2012 Author Share Posted November 26, 2012 And yes, I'm checking GET because the productID is set on the first page, however I want to parse the information relating to the GET variable onto the shopping cart in POST (so it cant be edited). Why am I such a tard? Can't do this. Must practice. Quote Link to comment https://forums.phpfreaks.com/topic/271212-simple-answer-im-a-tard-form-submission-problem/#findComment-1395332 Share on other sites More sharing options...
Jessica Posted November 26, 2012 Share Posted November 26, 2012 POST can most definitely be edited. Very easily. Quote Link to comment https://forums.phpfreaks.com/topic/271212-simple-answer-im-a-tard-form-submission-problem/#findComment-1395336 Share on other sites More sharing options...
samjslater Posted November 26, 2012 Author Share Posted November 26, 2012 antibang.com/selfassemblygifts/form.php When you click on an item in section A, you load a set of pictures and variables which can then be sent to a shopping cart (section c). The only problem that is occuring is when the form is submitted it doesn't detect if SANTA101 exists in the "discount code", it just rolls on ahead and uses the default price. I want it to see if the discount code is correct, amend the price, and THEN go to the shopping cart. Any clues? thanks alot for your help. Much appreciated. x Quote Link to comment https://forums.phpfreaks.com/topic/271212-simple-answer-im-a-tard-form-submission-problem/#findComment-1395341 Share on other sites More sharing options...
Muddy_Funster Posted November 26, 2012 Share Posted November 26, 2012 if($_GET['promo'] = "SANTA101") that's the wrong opperator for a comparison, It's maybe not the actual problem, but it's sure gonna be one if it isn't. Quote Link to comment https://forums.phpfreaks.com/topic/271212-simple-answer-im-a-tard-form-submission-problem/#findComment-1395343 Share on other sites More sharing options...
Jessica Posted November 26, 2012 Share Posted November 26, 2012 The URL that it submits to does NOT contain any vars in the query string, so $_GET is not the right thing to use. check if $_POST is set. Quote Link to comment https://forums.phpfreaks.com/topic/271212-simple-answer-im-a-tard-form-submission-problem/#findComment-1395346 Share on other sites More sharing options...
samjslater Posted November 27, 2012 Author Share Posted November 27, 2012 Right, so i've sorted many many things. Thank you so much for your help. The last thing I can't do is get a redirect to send this collected form information at the top of the page, to the specified location in the top of the form (ocho'd a few lines down). Thoughts? if($_GET['productID'] == 1){ $productNAME = "Limited Edition"; $productDESCRIPTION = "Self Assembly Gifts: Limited edition bauble in display box."; $productPRICE = "14.99"; $productDISCOUNT = "10.99"; $qty = $_POST['qty']; if($_POST['promo'] == "SANTA101"){ $value = $productDISCOUNT; } else { $value = $productPRICE; } if($_POST['action'] == "Submit Form"){ echo ' <form action="http://ww7.aitsafe.com/cf/add.cfm" method="post"> <input name="userid" type="hidden" value="94285118" /> <input name="product" type="hidden" value="'.$productNAME.'" /> <input name="productID" type="hidden" value="'. $_GET['productID'].'" /> <input name="qty" type="hidden" value="'.$qty.'" /> <input name="price" type="hidden" value="'.$value.'" /> </form> '; exit; } Quote Link to comment https://forums.phpfreaks.com/topic/271212-simple-answer-im-a-tard-form-submission-problem/#findComment-1395484 Share on other sites More sharing options...
Muddy_Funster Posted November 27, 2012 Share Posted November 27, 2012 what's actualy in $_POST['action'] ? Quote Link to comment https://forums.phpfreaks.com/topic/271212-simple-answer-im-a-tard-form-submission-problem/#findComment-1395489 Share on other sites More sharing options...
samjslater Posted November 27, 2012 Author Share Posted November 27, 2012 I'm using an image to submit the form, so i have a hidden input called 'action' which I use to trigger that variable at the top. It does work because I can see the form information in the source when I submit the form. The variables seem to have to be collected at the top of the page, and then, once collected they're sent to the cart. I just cant get them to send. What is the simplest way to send this all the form information to: http://ww7.aitsafe.com/cf/add.cfm Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/271212-simple-answer-im-a-tard-form-submission-problem/#findComment-1395492 Share on other sites More sharing options...
mrMarcus Posted November 27, 2012 Share Posted November 27, 2012 When I submit the form on your site I receive the following on the next page: Price = Promo = SANTA101 Product ID = 2 Quote Link to comment https://forums.phpfreaks.com/topic/271212-simple-answer-im-a-tard-form-submission-problem/#findComment-1395515 Share on other sites More sharing options...
mrMarcus Posted November 27, 2012 Share Posted November 27, 2012 (edited) http://antibang.com/...ID=2#ad-image-0 I do not see where you have the following form on that page: <form action="http://ww7.aitsafe.com/cf/add.cfm" method="post"> <input name="userid" type="hidden" value="94285118" /> <input name="product" type="hidden" value="'.$productNAME.'" /> <input name="productID" type="hidden" value="'. $_GET['productID'].'" /> <input name="qty" type="hidden" value="'.$qty.'" /> <input name="price" type="hidden" value="'.$value.'" /> </form> Edited November 27, 2012 by mrMarcus Quote Link to comment https://forums.phpfreaks.com/topic/271212-simple-answer-im-a-tard-form-submission-problem/#findComment-1395518 Share on other sites More sharing options...
samjslater Posted November 27, 2012 Author Share Posted November 27, 2012 Sorry mrMarcus. There's been a cock up. Here is it as clearly as possible: http://antibang.com/selfassemblygifts/shop.php?productID=2#ad-image-0 Submit the form with the code: SANTA101 in the discount box. Once the form is submitted, view source on the page and: <form action="http://ww7.aitsafe.com/cf/add.cfm" method="post"> <input name="userid" type="hidden" value="94285118" /> <input name="product" type="hidden" value="'.$productNAME.'" /> <input name="productID" type="hidden" value="'. $_GET['productID'].'" /> <input name="qty" type="hidden" value="'.$qty.'" /> <input name="price" type="hidden" value="'.$value.'" /> </form> Will be at the top. How do I get that info to pass to the http:// at the top of the form? Quote Link to comment https://forums.phpfreaks.com/topic/271212-simple-answer-im-a-tard-form-submission-problem/#findComment-1395521 Share on other sites More sharing options...
mrMarcus Posted November 27, 2012 Share Posted November 27, 2012 Do you know how HTML forms work? You have that form stuck up at the top of the page (above the DOCTYPE), and without a button to call the form to action. Quote Link to comment https://forums.phpfreaks.com/topic/271212-simple-answer-im-a-tard-form-submission-problem/#findComment-1395524 Share on other sites More sharing options...
mrMarcus Posted November 27, 2012 Share Posted November 27, 2012 When the user clicks the "Go to cart" button, you should then swap out the current form with the payment form: <form action="http://ww7.aitsafe.com/cf/add.cfm" method="post"> <input name="userid" type="hidden" value="94285118" /> <input name="product" type="hidden" value="Standard Edition" /> <input name="productID" type="hidden" value="2" /> <input name="qty" type="hidden" value="1" /> <input name="price" type="hidden" value="5.99" /> </form> And replace the "Go to cart" button with something like "Checkout »" with details of their pending purchase in place of the Quantity/Promo boxes. This is just a quick, easy fix. I don't like the process design of your cart IMO. I would also recommend auto-populating the Quantity input box with 1 as the customer will always purchase at least 1 of something. Quote Link to comment https://forums.phpfreaks.com/topic/271212-simple-answer-im-a-tard-form-submission-problem/#findComment-1395525 Share on other sites More sharing options...
Iluvatar+ Posted November 27, 2012 Share Posted November 27, 2012 echo '<pre>'; print_r($_POST); echo ''</pre>; :| check Quote Link to comment https://forums.phpfreaks.com/topic/271212-simple-answer-im-a-tard-form-submission-problem/#findComment-1395542 Share on other sites More sharing options...
Muddy_Funster Posted November 27, 2012 Share Posted November 27, 2012 you may want to edit that last echo there.... Quote Link to comment https://forums.phpfreaks.com/topic/271212-simple-answer-im-a-tard-form-submission-problem/#findComment-1395543 Share on other sites More sharing options...
Iluvatar+ Posted November 27, 2012 Share Posted November 27, 2012 echo '<pre>'; print_r($_POST); echo '</pre>'; :| check Quote Link to comment https://forums.phpfreaks.com/topic/271212-simple-answer-im-a-tard-form-submission-problem/#findComment-1395549 Share on other sites More sharing options...
mrMarcus Posted November 27, 2012 Share Posted November 27, 2012 echo '<pre>'; print_r($_POST); echo ''</pre>; :| check Proper communication goes a long way. I have know idea what you're talking about. We have now just wasted time while I wait for proper reply from you. Quote Link to comment https://forums.phpfreaks.com/topic/271212-simple-answer-im-a-tard-form-submission-problem/#findComment-1395551 Share on other sites More sharing options...
Iluvatar+ Posted November 27, 2012 Share Posted November 27, 2012 Well i apologise for my lack of response. From my observation it seems there was confusion between $_GET and $_POST. Quote Link to comment https://forums.phpfreaks.com/topic/271212-simple-answer-im-a-tard-form-submission-problem/#findComment-1395554 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.