esoteric Posted July 22, 2011 Share Posted July 22, 2011 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 More sharing options...
esoteric Posted July 22, 2011 Author Share Posted July 22, 2011 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.