Jump to content

Recommended Posts

Thanks to teynon we solved a problem i had yesterday, but that had led to a new problem.

 

I want to save my form data to a database. The form itself is a checkout form, it sends me an email of all the items a customer wants (products are made to order) so i then reply to each one. I want to save the customer name, order number and date it was ordered to a database.

 

The order form is targeting a file called 'checkout_process.php', in this script the order number is generated before the email is sent;

 

$today = date('l jS F Y h:i:s A');
$strMessageBody = "$REMOTE_ADDR\n";
$strMessageBody .= "Order Date : $today \n";
$strMessageBody .= "Your Order Number #";
$strMessageBody .= $order = date ("dmyHis\n");
$strMessageBody .= "We have received your order for processing.\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_zip \n";
$strMessageBody .= "   $b_phone \n";
$strMessageBody .= "   $b_fax \n";
$strMessageBody .= "   $b_email \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 .= "TOTAL: $TOTAL \n";
$strMessageBody .= "\n";
$strMessageBody .= "Comments: \n";
$strMessageBody .= "--------- \n";
$strMessageBody .= "$comment \n";
$strMessageBody .= " \n";
$strMessageBody .= "Please contact us at $youremail. If you have any questions or concerns, please reference your OrderID# $order."; 

 

How can i grab some of these details and send them too the sql database before/when the email sends?

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/242615-send-data-to-mysql/
Share on other sites

I wrote

 // save to database
mysql_connect("xxx.xxx.com", "$username", "$password");
mysql_select_db("membership") or die( "Unable to select database");
$query = "INSERT INTO orderTable ('user_id', 'id', 'orderNum', 'orderDate', 'custEmail', 'firstName', 'lastName') VALUES ('&user_id', '', $order', '$today', '$b_email', '$b_first', '$b_last')";
// save end

 

but it still isn't adding anything to the table

Link to comment
https://forums.phpfreaks.com/topic/242615-send-data-to-mysql/#findComment-1246073
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.