checkout.php

Problems installing or using the NOP Design Free Shopping Cart that do not fit into one of the above categories.

Moderators: Koibito, Stefko, Randy

checkout.php

Postby madisonfriday » Thu Jul 15, 2010 3:45 pm

I cannot for the life of me get it to work!

I have the code set up in checkout.html

and then the php...


but everytime I get this error

The form you submitted was not complete.

I'm sorry, but it appears that you forgot to fill in a required field. Please go back and correct the error.


I filled out EVERY field - what the heck!!

my code

Code: Select all
//######################################################################
$header        = "header.html";
$footer        = "footer.html";
$returnpage    = "/";
$youremail     = "madisonfriday@gmail.com";
$csvfilename   = "orders.csv";
$csvquote      = "\"\"";
$mode          = "EMAIL";


//##############################################################
//#FUNCTION:   doFormError                                     #
//#RETURNS:                                                    #
//#PARAMETERS: A error message string.                         #
//#PURPOSE:    Generates an HTML page indicating a form        #
//#            submission error occurred.                      #
//##############################################################
function doFormError($errString) {

    include($header);

    echo "<FONT SIZE=+2>The form you submitted was not complete.<BR><BR></FONT>";
    echo "$errString<BR><BR>\n";
    echo "<INPUT TYPE=BUTTON ONCLICK='history.back()' VALUE='  Return to the checkout page '><HR>";

    include($footer);

    exit;
}

//##############################################################
//#FUNCTION:   doError                                         #
//#RETURNS:                                                    #
//#PARAMETERS: A error message string.                         #
//#PURPOSE:    Generates an HTML page indicating an error      #
//#            occurred.                                       #
//##############################################################
function doError($errString) {

    include($header);

    echo "$errString<BR><BR>\n";

    include($footer);

    exit;
}



//##############################################################
//##############################################################
//###  MAIN                                                  ###
//##############################################################
//##############################################################

if (($b_first == "") || ($b_last == "") || ($b_addr == "") || ($b_city == "") || ($b_state == "") || ($b_zip == "") || ($b_phone == "") || ($b_email == "")) {
   doFormError("I'm sorry, but it appears that you forgot to fill in a required field.  Please go <A HREF='Javascript:history.go(-1);'>back</A> and correct the error.");
   exit;
}

//# checks for valid email address
if( !(ereg("^(.+)@(.+)\\.(.+)$",$b_email)) ) {
    doFormError("You submitted an invalid email address.  Please go <A HREF='Javascript:history.go(-1);'>back</A> and correct the error.");
    exit;
}

$today = date ("l, F jS Y");
$strMessageBody = "";
$strMessageBody .= "A new order has been received.  A summary of this order appears below.\n";
$strMessageBody .= "\n";
$strMessageBody .= "Order Date: $today \n";
$strMessageBody .= " \n";
$strMessageBody .= "Bill To: \n";
$strMessageBody .= "-------- \n";
$strMessageBody .= "   $b_first $b_last \n";
$strMessageBody .= "   $b_addr \n";
$strMessageBody .= "   $b_addr2 \n";
$strMessageBody .= "   $b_city, $b_state  $b_zip \n";
$strMessageBody .= "   $b_phone \n";
$strMessageBody .= "   $b_fax \n";
$strMessageBody .= "   $b_email \n";
$strMessageBody .= " \n";
$strMessageBody .= " \n";
$strMessageBody .= "Ship To: \n";
$strMessageBody .= "-------- \n";
$strMessageBody .= "   $s_first $s_last \n";
$strMessageBody .= "   $s_addr \n";
$strMessageBody .= "   $s_addr2 \n";
$strMessageBody .= "   $s_city, $s_state  $s_zip \n";
$strMessageBody .= "   $s_phone \n";
$strMessageBody .= " \n";
$strMessageBody .= " \n";
$strMessageBody .= "Qty  Price(\$)   Product ID  - Product Name\n";
$strMessageBody .= "===================================================================== \n";
$strMessageBody .= "$QUANTITY_1    \$$PRICE_1    $ID_1 - $NAME_1   $ADDTLINFO_1  \n";
if( $NAME_2 ) {$strMessageBody .= "$QUANTITY_2    \$$PRICE_2    $ID_2 - $NAME_2   $ADDTLINFO_2  \n";}
if( $NAME_3 ) {$strMessageBody .= "$QUANTITY_3    \$$PRICE_3    $ID_3 - $NAME_3   $ADDTLINFO_3  \n";}
if( $NAME_4 ) {$strMessageBody .= "$QUANTITY_4    \$$PRICE_4    $ID_4 - $NAME_4   $ADDTLINFO_4  \n";}
if( $NAME_5 ) {$strMessageBody .= "$QUANTITY_5    \$$PRICE_5    $ID_5 - $NAME_5   $ADDTLINFO_5  \n";}
if( $NAME_6 ) {$strMessageBody .= "$QUANTITY_6    \$$PRICE_6    $ID_6 - $NAME_6   $ADDTLINFO_6  \n";}
if( $NAME_7 ) {$strMessageBody .= "$QUANTITY_7    \$$PRICE_7    $ID_7 - $NAME_7   $ADDTLINFO_7  \n";}
if( $NAME_8 ) {$strMessageBody .= "$QUANTITY_8    \$$PRICE_8    $ID_8 - $NAME_8   $ADDTLINFO_8  \n";}
if( $NAME_9 ) {$strMessageBody .= "$QUANTITY_9    \$$PRICE_9    $ID_9 - $NAME_9   $ADDTLINFO_9  \n";}
if( $NAME_10 ){$strMessageBody .= "$QUANTITY_10    \$$PRICE_10    $ID_10 - $NAME_10   $ADDTLINFO_10 \n";}
if( $NAME_11 ){$strMessageBody .= "$QUANTITY_11    \$$PRICE_11    $ID_11 - $NAME_11   $ADDTLINFO_11 \n";}
if( $NAME_12 ){$strMessageBody .= "$QUANTITY_12    \$$PRICE_12    $ID_12 - $NAME_12   $ADDTLINFO_12 \n";}
if( $NAME_13 ){$strMessageBody .= "$QUANTITY_13    \$$PRICE_13    $ID_13 - $NAME_13   $ADDTLINFO_13 \n";}
$strMessageBody .= "===================================================================== \n";
$strMessageBody .= "SUBTOTAL: $SUBTOTAL \n";
$strMessageBody .= "TOTAL: $TOTAL \n";
$strMessageBody .= "\n";
$strMessageBody .= "FREIGHT: $SHIPPING \n";
$strMessageBody .= "\n\n";
$strMessageBody .= "Comments: \n";
$strMessageBody .= "--------- \n";
$strMessageBody .= "$comment \n";
$strMessageBody .= " \n";


if( $mode == "BOTH" || $mode == "EMAIL") {
   //# Send email order to you...
   $mailheaders = "From: $b_email\r\n";
   $mailheaders .="X-Mailer: PHP Mail generated by:NOP Design Shopping Cart\r\n";
   $subject = "New Online Order";
   mail($youremail, $subject, $strMessageBody, $mailheaders);
}


if( $mode == "BOTH" || $mode == "FILE") {
   
   $csvcomments = $comment;
   if (!$CSVF = fopen($csvfilename,'a')) {
       doError("Unable to open CSV file for writing.  Your order has not been saved.");
       exit;
   }

   fputs($CSVF, $string);
   fputs($CSVF, "\"");
   fputs($CSVF, "$today");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_first");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_last");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_addr");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_addr2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_city");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_state");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_zip");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_phone");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_fax");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_email");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_first");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_last");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_addr");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_addr2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_city");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_state");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_zip");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_phone");
   fputs($CSVF, "\",\"");   
   fputs($CSVF, "$QUANTITY_1");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_1");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_1");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_1");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_1");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_3");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_3");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_3");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_3");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_3");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_4");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_4");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_4");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_4");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_4");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_5");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_5");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_5");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_5");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_5");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_6");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_6");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_6");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_6");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_6");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_7");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_7");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_7");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_7");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_7");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_8");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_8");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_8");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_8");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_8");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_9");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_9");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_9");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_9");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_9");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_10");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_10");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_10");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_10");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_10");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_11");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_11");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_11");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_11");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_11");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_12");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_12");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_12");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_12");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_12");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_13");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_13");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_13");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_13");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_13");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$SUBTOTAL");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$TOTAL");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$SHIPPING");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$comment");
   fputs($CSVF, "\"\n");
   
   fclose($CSVF);
}

//# Send email conformation to the customer.....
$mailheaders = "From: $youremail\r\n";
$mailheaders .="X-Mailer: PHP Mail generated by:NOP Design Shopping Cart\r\n";
$subject = "Order Confirmation";
mail($b_email, $subject, $strMessageBody, $mailheaders);

include($header);

echo "<h2>Thank you</h2>";
echo "Thank you for your order from our online store.  You will receive a confirmation email of your order ";
echo "momentarily.  Please contact us at $youremail if you have any questions or concerns.";
echo "<P>";
echo "<A HREF=\"$returnpage\" target=_top>Return Home</A>";
echo "<P>";

include($footer);

?>




Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Checkout - Mo Cigars</title>
<link href="../css/css.css" rel="stylesheet" type="text/css" />
   <!--[if IE 7]>
      <link rel="stylesheet" type="text/css" href="../css/css-ie.css" />
   <![endif]-->
<SCRIPT SRC="language-en.js"></SCRIPT>
<SCRIPT SRC="nopcart.js">
</SCRIPT>
<SCRIPT>
function CheckForm( theform )
{
   var bMissingFields = false;
   var strFields = "";
   
   if( theform.b_first.value == '' ){
      bMissingFields = true;
      strFields += "     Billing: First Name\n";
   }
   if( theform.b_last.value == '' ){
      bMissingFields = true;
      strFields += "     Billing: Last Name\n";
   }
   if( theform.b_addr.value == '' ){
      bMissingFields = true;
      strFields += "     Billing: Address\n";
   }
   if( theform.b_city.value == '' ){
      bMissingFields = true;
      strFields += "     Billing: City\n";
   }
   if( theform.b_state.value == '' ){
      bMissingFields = true;
      strFields += "     Billing: State\n";
   }
   if( theform.b_zip.value == '' ){
      bMissingFields = true;
      strFields += "     Billing: Zipcode\n";
   }
   if( theform.b_phone.value == '' ){
      bMissingFields = true;
      strFields += "     Billing: Phone\n";
   }
   if( theform.b_email.value == '' ){
      bMissingFields = true;
      strFields += "     Billing: Email\n";
   }
      
   if( bMissingFields ) {
      alert( "I'm sorry, but you must provide the following field(s) before continuing:\n" + strFields );
      return false;
   }
   
   return true;
}
</SCRIPT>
</head>

<body>
<div class="main-container">
   <a href="../index.html"><img class="logo" src="../images/logo.png"  /></a>
    <a href="../cart/manage.html"><img class="cart" src="../images/cart.png" /></a>
      <div class="nav">
       <ul>
<li><a href="../about.html">About</a></li>
            <li><a href="../cigars.html">Cigars</a></li>
            <li><a href="../lighters.html">Lighters</a></li>
            <li><a href="../humidors.html">Humidors</a></li>
<li><a href="../cigar101.html">Cigar 101</a></li>
            <li><a href="../contact.html">Contact Us</a></li>
    </div>
    <div class="main-content" style="padding:0; height:1500px;">
  <div class="check-out">
  <!--Shopping Cart Checkout Begin-->
    The items listed below are currently in your shopping cart:
  <!--Shopping Cart Checkout Begin-->
    The items listed below are currently in your shopping cart:
<blockquote>

<NOSCRIPT>
Whoops, we detected that your browser does not have JavaScript, or it is disabled.  Our product catalog requires that you
have JavaScript enabled to order products.  <a href="http://www.netscape.com">Netscape</a> and <a href="http://www.microsoft.com/ie">Microsoft</a>
offer free browsers which support JavaScript.  If you are using a JavaScript compliant browser and still have problems, make sure you
have JavaScript enabled in your browser's preferences.
</NOSCRIPT>
<FONT CLASS="checkout">
<!-- If you wish to use the PHP checkout instead of perl, just replace the /cgi-bin/checkout.pl below with checkout.php -->
<form action="checkout.php" method="POST" onSubmit="return CheckForm(this)">
    <NOBR>
    <SCRIPT>
        CheckoutCart();
    </SCRIPT>
    </NOBR>
<br>
<P>
<font class="blacktext">
<b>Please fill out the following information below to complete your order.</b>
</font>

<p>
<b><font class="greetext">Billing Information:</font></b><P>

<TABLE class="blacktext">
<TR><TD>Name:    </TD><TD><input type="text" size="18" name="b_first"> <input type="text" size="15" name="b_last"></TD></TR>
<TR><TD>Address: </TD><TD><input type="text" size="37" name="b_addr"> </TD></TR>
<TR><TD>Address: </TD><TD><input type="text" size="37" name="b_addr2"></TD></TR>
<TR><TD>City:    </TD><TD><input type="text" size="21" name="b_city"> </TD></TR>
<TR><TD>State:   </TD><TD><input type="text" size="1"  name="b_state"> </TD></TR>
<TR><TD>Zip:     </TD><TD><input type="text" size="5"  name="b_zip"></TD></TR>
<TR><TD>Phone:   </TD><TD><input type="text" size="37" name="b_phone"></TD></TR>
<TR><TD>Fax:     </TD><TD><input type="text" size="37" name="b_fax"></TD></TR>
<TR><TD>Email:   </TD><TD><input type="text" size="37" name="b_email"> </TD></TR>
</TABLE>
<p>
<b><font class="greetext">Shipping Information (if different than billing):</font></b><P>
<TABLE class="blacktext">
<TR><TD>Name:    </TD><TD><input type="text" size="18" name="s_first"> <input type="text" size="15" name="s_last"></TD></TR>
<TR><TD>Address: </TD><TD><input type="text" size="37" name="s_addr"> </TD></TR>
<TR><TD>Address: </TD><TD><input type="text" size="37" name="s_addr2"></TD></TR>
<TR><TD>City:    </TD><TD><input type="text" size="21" name="s_city"> </TD></TR>
<TR><TD>State:   </TD><TD><input type="text" size="1"  name="s_state"> </TD></TR>
<TR><TD>Zip:     </TD><TD><input type="text" size="5"  name="s_zip"></TD></TR>
<TR><TD>Phone:   </TD><TD><input type="text" size="37" name="s_phone"></TD></TR>
<TR><TD>Fax:     </TD><TD><input type="text" size="37" name="s_fax"></TD></TR>
<TR><TD>Email:   </TD><TD><input type="text" size="37" name="s_email"> </TD></TR>
</TABLE>
<p>
<FONT class="blacktext">
<b><font class="greetext">Comments/Special Instructions:</font></b><P>
<TEXTAREA NAME="comment" ROWS=6 COLS=40>
</TEXTAREA>
</font>
<p>
<input type=submit Value="Submit Order"> <INPUT type=RESET value="  Clear Form  ">
    </p>
    </center>   
    </FORM>   
</blockquote>
    </div>
   
<div class="footer"><p>All Rights Reserved. Copyright 2010.<br /><img src="../images/cards.png" /></p>
</div>
</body>
</html>

madisonfriday
WebMaster
 
Posts: 6
Joined: Wed Jul 07, 2010 5:49 pm

Re: checkout.php

Postby Koibito » Thu Jul 15, 2010 4:50 pm

Do a search for 'Globals'.
John
Koibito
Site Admin / Guru
 
Posts: 918
Joined: Sun May 28, 2006 1:59 am
Location: New Jersey, USA


Return to Help: Cart / General

Who is online

Users browsing this forum: wuhuilin11 and 5 guests