使用Oracle导致php邮件

时间:2014-03-02 15:38:30

标签: php sql oracle email

我对PHP很新,并且制作并订购了触发电子邮件确认的表单。选择产品的方式是通过下拉列表,其中返回值与产品ID相关,因此我无法插入产品ID。

我想创建一个运行以使ID与名称匹配的查询,并在电子邮件中显示该名称。到目前为止,我有:

$conn = oci_connect('user', 'password', 'mydb');

$strSQL = "INSERT INTO ONLINE_ORDER ";  
$strSQL .="(FIRST_NAME, LAST_NAME, EMAIL, ADDRESS_LINE_1, ADDRESS_LINE_2, ADDRESS_LINE_3, POSTCODE, PHONE_NUMBER, QUANTITY, PRODUCT_ID) ";  
$strSQL .="VALUES ";  
$strSQL .="('".$_POST["FirstName"]."','".$_POST["LastName"]."','".$_POST["Email"]."','".$_POST["Address1"]."','".$_POST["Address2"]."','".$_POST["Address3"]."','".$_POST["Postcode"]."','".$_POST["PhoneNumber"]."','".$_POST["qtyA"]."','".$_POST["product"]."') ";

$objParse = oci_parse($conn, $strSQL);  
$objExecute = oci_execute($objParse, OCI_DEFAULT);  
if($objExecute)  
{  
oci_commit($conn);

echo "<font style='color:#666666' style='Verdana, Arial, Helvetica, sans-serif'>";
echo "Your order has been placed successfully, please wait and you should receive a confirmation email shortly.";
echo "<br /><br />To create a new order please go to our <a href=http://apex.cowplainturf.com/uniorder.php>Order Page</a>.";
echo "To continue browsing our site, please return to the <a href=http://www.cowplainturf.com/index.html>Home Page</a></font>";

$email = "enquiries@mywebsite.co.uk";
$to = $_POST["Email"];
$subject = "Your Order with the Company";
$headers = "From: $email\n";

$emailSQL = "SELECT PRODUCT_NAME FROM PRODUCT WHERE PRODUCT_ID = ".$_POST["product"]."";
$emailParse = oci_parse($conn, $emailSQL);  
$emailExecute = oci_execute($emailParse, OCI_DEFAULT);
while (oci_fetch($emailExecute)) {
    $emailresult = oci_result($emailExecute, 'PRODUCT_NAME')."";
}

$message = "Contact Summary: \n \n First Name: ".$_POST['FirstName']." of ";
$message .= "\n Last Name: ".$_POST['LastName']."\n Email: ".$_POST['Email']."";
$message .= "\n Address Line 1: ".$_POST['Address1']."";
$message .= "\n Address Line 2: ".$_POST['Address2']."";
$message .= "\n Address Line 3: ".$_POST['Address3']."";
$message .= "\n Postcode: ".$_POST["Postcode"]."";
$message .= "\n \n \n Order Summary: \n \n You ordered ".$_POST['qtyA']."";
$message .= " of ";
$message .= "".$row['PRODUCT_NAME']."";


mail($to,$subject,$message,$headers);

非常感谢,帮助将不胜感激!

0 个答案:

没有答案