Jump to content

Recommended Posts

Hi all,

 

Some years ago I created a website for a friend of mine that included NOPDesign's free shopping cart.

 

Everything was set up and working fine, and then she told me that the checkout page wasn't working any more. I went to the website and filled out a "dummy form" and sure enough, no matter how completely I filled out the form, I always got the same error message - that I'd skipped a required field and needed to fill it in. It also tells me that the email address is invalid, even though it's a valid one.

 

I didn't change anything in the script and have no idea why it suddenly isn't working.  Can someone please give me a hand?

 

The website is www.elliestravellingtots.com.  Here is the code I have for the customer form to fill out:

 

<TABLE class="blacktext">
<TR><TD>Name:    </TD><TD><input type="text" 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>

 

 

And here is the 'error generating' code in the checkout.php:

 

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

 

Please let me know if there's anything else you need from me to solve this problem. Thank you oh thank you!

 

 

Thanks for the answer! So are you saying that instead of the HTML saying "name = "$b_first", that it needs to say "name = "$_POSTb_first", and so on?  I know nothing about PHP code so I want to make sure I get it right.

 

Thanks again for your help!

OK, thanks.  I changed the PHP to this:

 

if (($_POST['b_first'] == "") || ($_POST['b_last'] == "") || ($_POST['b_addr'] == "") || ($_POST['b_city'] == "") || ($_POST['b_state'] == "") || ($_POST['b_zip'] == "") || ($_POST['b_phone'] == "") || ($_POST['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.");

 

but I'm still getting the error, even though I filled in all the required lines. I'm guessing I misunderstood something?

 

Thanks again.

Edited by SarahB1863

unless the form code you posted is part of a php echo statement, the name="$b_first" attributes don't make any sense as the php variables they would cause to be submitted would contain the $ as part of the name.

 

what version of this cart software is this, so that someone could download it to examine? and where did you down load this from, as the NOPDesgin site i found has a purely javascript cart, no php involved.

Edited by mac_gyver

It's V.4.4.0. 

 

I downloaded it from nopdesign.com, but this was in 2007 so they may have removed the script.

 

Oddly, the header of the script says it's PHP and Javascript both:

 

  NOP Design JavaScript Shopping Cart                   ||
//                   PHP SCRIPT Checkout Module                        ||
//                                                                     ||
// For more information on SmartSystems, or how NOPDesign can help you ||
// Please visit us on the WWW at http://www.nopdesign.com              ||
//                                                                     ||
// Javascript portions of this shopping cart software are available as ||
// freeware from NOP Design.  You must keep this comment unchanged in  ||
// your code.  For more information contact FreeCart@NopDesign.com.    ||
//                                                                     ||
// JavaScript Shop Module, V.4.4.0                                     ||
//=====================================================================||
//                                                                     ||
//  Function: Writes available form elements from the NOP              ||
//            Free Cart (http://www.nopdesign.com/freecart)            ||
//            and other form elements to an email file, and            ||
//            send user confirmation     

 

 

I'll be happy to email the file if it isn't downloadable.

Edited by SarahB1863

the current demo download (not just the nopcart js files) contains a checkout form similar to the one you posted, with name attributes like - name="b_first" (i.e. no leading $ on the names.)

 

are you sure you didn't add those $ to the form field name attributes recently?

 

in any case, for a form field with a name attributed of - name="b_first" the corresponding php variable would be $_POST['b_first']

I don't remember adding the $ signs (I don't know anything about PHP coding, in case you couldn't tell!), but I've messed around with this script so much trying to get it to work that anything's possible!

 

I'll try removing the dollar signs from the checkout form HTML, and change the PHP script to include the $_POST, and see if that does the trick.

 

Thanks again for all your help.

OK, I think I'm getting closer but I'm not sure.

 

I removed all the dollar signs from the input fields in the form, and altered the PHP script so the error portion looks like this:

 

if (($_POST['b_first'] == "") || ($_POST['b_last'] == "") || ($_POST['b_addr'] == "") || ($_POST['b_city'] == "") || ($_POST['b_state'] == "") || ($_POST['b_zip'] == "") || ($_POST['b_phone'] == "") || ($_POST['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("^(.+)@(.+)\\.(.+)$",$_POST['b_email'])) ) {
    doFormError("You submitted an invalid email address.  Please go <A HREF='Javascript:history.go(-1);'>back</A> and correct the error.");
    exit;
}
 

The form seems to get by the customer info OK, but is still tellng me I'm entering an invalid email address when I just put an 'x' in the input field. Fair enough, but when I put in my correct email address I get this message:

 

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

 

 

I'm sure I've done something wrong, but I'm not sure what.  Any help would be appreciated, thanks.

if the 500 server error is occurring on the form processing page (the address in your browser hasn't changed), it's likely that a fatal php runtime error has occurred further down in the code.

 

add the following two lines of php code, immediately after the first opening <?php tag, to get php to report and display any errors it detects -

ini_set("display_errors", "1");
error_reporting(-1);

Thank you! I tried that and got a bunch of these:

 

Notice: Undefined variable: b_first in /home/content/e/l/l/ellie1976/html/checkout.php on line 135

Notice: Undefined variable: b_last in /home/content/e/l/l/ellie1976/html/checkout.php on line 135

Notice: Undefined variable: b_addr in /home/content/e/l/l/ellie1976/html/checkout.php on line 136

 

Etc.  Basically every variable is 'undefined'.  Do I need to add the $_POST somewhere else, or is it another problem?

 

I also got:

No recipient addresses found in header

 

 

But I can probably figured that one out...

if the $b_first, ... variables later in the code represent the same values (form data) as the code already posted in this thread (it would take knowing what the code between those two points is doing), then yes, either they would need to be replaced with the corresponding $_POST variable or you could assign the post variable to the named variable at some point in the code - $b_first = $_POST['b_first']; (which method depends on how many places the variables like $b_first are used.)

 

please be advised that there are other changes in php that accompany the change that resulted in the $b_first, ... variables from external data (post, get, cookie) to no longer exist. i recommend that you read the php migration guides in the php.net documentation appendix to see what exactly has been changed over time in the php versions that you might need to address in your code.

in general we only want to see relevant code. as long as this isn't more than a few hundred lines, go ahead. if we are talking 1000's of lines of code, no.

 

Please use the forum's


bbcode tags (the edit form's <> button) around the posted code.
 

Here it is. This includes the PHP code I changed (in the error section.)

 

 

<?
ini_set("display_errors", "1");
error_reporting(-1);
//=====================================================================||
//               NOP Design JavaScript Shopping Cart                   ||
//                   PHP SCRIPT Checkout Module                        ||
//                                                                     ||
// For more information on SmartSystems, or how NOPDesign can help you ||
// Please visit us on the WWW at http://www.nopdesign.com              ||
//                                                                     ||
// Javascript portions of this shopping cart software are available as ||
// freeware from NOP Design.  You must keep this comment unchanged in  ||
// your code.  For more information contact FreeCart@NopDesign.com.    ||
//                                                                     ||
// JavaScript Shop Module, V.4.4.0                                     ||
//=====================================================================||
//                                                                     ||
//  Function: Writes available form elements from the NOP              ||
//            Free Cart (http://www.nopdesign.com/freecart)            ||
//            and other form elements to an email file, and            ||
//            send user confirmation                                   ||
//                                                                     ||
//=====================================================================||


//######################################################################
//                                                                     #
// User defined variables:                                             #
//     $header        - string value containing the complete           #
//                      path of the HTML page header                   #
//     $footer        - string value containing the complete           #
//                      path of the HTML page footer                   #
//     $youremail     - string value containing the email address to   #
//                      send catalog orders in EMAIL or BOTH modes     #
//     $returnpage    - URL to send user when checkout is complete     #
//     $csvfilename   - string value containing the complete           #
//                      path of the user database.                     #
//     $csvquote      - string value containing what to use for quotes #
//                      in the csv file (typically "" or \")           #
//     $mode          - string value containing 'EMAIL', 'FILE' or     #
//                      'BOTH' to determine if the script should send  #
//                      an email to you with the new order, write the  #
//                      order to a CSV file, or do both.               #
//######################################################################
//$header        = "header.html";
//$footer        = "footer.html";
$returnpage    = "http://www.elliestravellingtots.com/thankyou.html";
$youremail     = "sas2001@bex.net";
$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 "<html>
        <head><title>www.ElliesTravellingTots.com</title></head>
        <body>";



    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>";
    echo "</body></html>";
        
//    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 "<html>
        <head><title>www.ElliesTravellingTots.com</title></head>
        <body>";

    echo "$errString<BR><BR>\n";
    echo "</body></html>";

//    include($footer);

    exit;
}



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

if (($_POST['b_first'] == "") || ($_POST['b_last'] == "") || ($_POST['b_addr'] == "") || ($_POST['b_city'] == "") || ($_POST['b_state'] == "") || ($_POST['b_zip'] == "") || ($_POST['b_phone'] == "") || ($_POST['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("^(.+)@(.+)\\.(.+)$", $_POST['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 "<html>
        <head><title>www.ElliesTravellingTots.com</title></head>
        <body>";

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>";
echo "</body></html>";

//include($footer);

?>
 

I changed the code, and it's working - sort of.  But when it gets to this set of lines:

 

 

if( $_POST['NAME_2'] ) {$strMessageBody .= "$QUANTITY_2    \$$PRICE_2    $ID_2 - $NAME_2   $ADDTLINFO_2  \n";}
if( $_POST['NAME_3'] ) {$strMessageBody .= "$QUANTITY_3    \$$PRICE_3    $ID_3 - $NAME_3   $ADDTLINFO_3  \n";}
if( $_POST['NAME_4'] ) {$strMessageBody .= "$QUANTITY_4    \$$PRICE_4    $ID_4 - $NAME_4   $ADDTLINFO_4  \n";}
if( $_POST['NAME_5'] ) {$strMessageBody .= "$QUANTITY_5    \$$PRICE_5    $ID_5 - $NAME_5   $ADDTLINFO_5  \n";}
if( $_POST['NAME_6'] ) {$strMessageBody .= "$QUANTITY_6    \$$PRICE_6    $ID_6 - $NAME_6   $ADDTLINFO_6  \n";}
if( $_POST['NAME_7'] ) {$strMessageBody .= "$QUANTITY_7    \$$PRICE_7    $ID_7 - $NAME_7   $ADDTLINFO_7  \n";}
if( $_POST['NAME_8'] ) {$strMessageBody .= "$QUANTITY_8    \$$PRICE_8    $ID_8 - $NAME_8   $ADDTLINFO_8  \n";}
if( $_POST['NAME_9'] ) {$strMessageBody .= "$QUANTITY_9    \$$PRICE_9    $ID_9 - $NAME_9   $ADDTLINFO_9  \n";}
if( $_POST['NAME_10'] ){$strMessageBody .= "$QUANTITY_10    \$$PRICE_10    $ID_10 - $NAME_10   $ADDTLINFO_10 \n";}
if( $_POST['NAME_11'] ){$strMessageBody .= "$QUANTITY_11    \$$PRICE_11    $ID_11 - $NAME_11   $ADDTLINFO_11 \n";}
if( $_POST['NAME_12'] ){$strMessageBody .= "$QUANTITY_12    \$$PRICE_12    $ID_12 - $NAME_12   $ADDTLINFO_12 \n";}
if( $_POST['NAME_13']){$strMessageBody .= "$QUANTITY_13    \$$PRICE_13    $ID_13 - $NAME_13   $ADDTLINFO_13 \n";}
 

 

It returns this error:

 

Notice: Undefined index: NAME_3 in /home/content/e/l/l/ellie1976/html/checkout.php on line 157

Notice: Undefined index: NAME_4 in /home/content/e/l/l/ellie1976/html/checkout.php on line 158

Notice: Undefined index: NAME_5 in /home/content/e/l/l/ellie1976/html/checkout.php on line 159

Notice: Undefined index: NAME_6 in /home/content/e/l/l/ellie1976/html/checkout.php on line 160

Notice: Undefined index: NAME_7 in /home/content/e/l/l/ellie1976/html/checkout.php on line 161

Notice: Undefined index: NAME_8 in /home/content/e/l/l/ellie1976/html/checkout.php on line 162

Notice: Undefined index: NAME_9 in /home/content/e/l/l/ellie1976/html/checkout.php on line 163

Notice: Undefined index: NAME_10 in /home/content/e/l/l/ellie1976/html/checkout.php on line 164

Notice: Undefined index: NAME_11 in /home/content/e/l/l/ellie1976/html/checkout.php on line 165

Notice: Undefined index: NAME_12 in /home/content/e/l/l/ellie1976/html/checkout.php on line 166

Notice: Undefined index: NAME_13 in /home/content/e/l/l/ellie1976/html/checkout.php on line 167

 

What I don't get is, all of those lines of code are the same, so why is it that I'm not getting an error for "Name 2"? It looks just like all the other lines.  It looks like I need to change something, but at this point I don't know what I need to change.

 

 

Any help is appreciated, thanks!!

I got the above problem fixed, but I can't find any way to delete the post, so just disregard, please.

 

So now, the code works - kind of. I put information into the fields, I hit submit, I get an email.

 

BUT - when I was updating the PHP code, in the variables, if I write the code like this:

 

$strMessageBody .= "   $_POST['b_first'] $_POST['b_last'] \n";

 

I get a syntax error.  But if I put a space between 'post' and the left bracket, like this:

 

$strMessageBody .= "   $_POST ['b_first'] $_POST ['b_last'] \n";

 

The syntax error goes away.  However, the information I get back from the form in my confirmation email looks like this:

 

Bill To:
--------
Array ['b_first'] Array ['b_last']
  Array ['b_addr']
  Array ['b_addr2']
  Array ['b_city'], Array ['b_state']  Array ['b_zip']
  Array ['b_phone']
  Array ['b_fax']
  Array ['b_email']

 

With none of the information that was put in the form present.
 

Any ideas what I'm doing wrong here? I mean, I know I'm not supposed to put those spaces in there, but why won't the code let me leave them out? Thanks again.

  • 2 weeks later...

"$_POST ['b_first'] $_POST ['b_last']"

 ------ ----------- ------ ----------

 

$_POST is certainly the name of an array variable. The fact that the brackets are disconnected from the variable name makes the brackets a literal string. Hence, they show in the email.

 

So, let's look at this:

" $_POST['b_first'] $_POST['b_last'] \n";

  ----------------- ----------------

 

$_POST is certainly the name of an array variable, but can PHP accurately determine if the brackets belong to the variable? Since there is some doubt, we may wish to force the issue and try one of two alternatives:

 

" ".$_POST['b_first']." ".$_POST['b_last']." \n";

This concatenates literal strings with stand-alone variables. Guaranteed to work.

 

" {$_POST['b_first']} {$_POST['b_last']} \n";

This encapsulates the entirety of the variable expression in braces. This may work.

Edited by bsmither
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.