Jump to content

Simple Answer, I'm A Tard - Form Submission Problem


samjslater

Recommended Posts

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>

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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;
}

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by mrMarcus
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.