PHP邮件脚本问题
我在 payment-status.php 文件中使用了邮件脚本。 我正在使用支付网关 API,用户在支付完成并成功后在 html 表单中填写所有详细信息,例如电话号码、电子邮件、地址等,并成功更新到“transaction_status”下名为“billing”的表中的数据库中'
问题是邮件程序脚本无法从事务成功的数据库中获取用户电子邮件 ID。 并且交易成功状态存储在不同的表中,而不是存储在存储用户详细信息的表中。
应该用于从交易成功的用户获取电子邮件 ID 的查询应该是这样的
$sql_query="Select email from billing_guest where transaction_status="transaction success"
这是我使用的邮件脚本。
$query = "SELECT email FROM billing_guests WHERE email = '" . $_POST["email"] . "'";
$result = mysql_query($query) or die(mysql_error());
$data = mysql_fetch_assoc($result);
$entry = mysql_num_rows($result);
//Check if entry exists
if($entry !== 0){
$message = $data['email'];
$to = "$_POST["email"]" ;
$from = "domain-id";
$Subject = "Hi";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-885n-l\r\n";
$headers .= "From: $from\r\n";
$message .="Thank You";
if(mail($to, $from, $subject, $message, $headers)){
echo 'Email sent';
}else{
echo 'Failed sending email';
}
}else{
echo 'No email entry found';
}
mysql_close($conn);
I have used a mailing script in my payment-status.php file.
I'm using a payment gateway API where a user fills up the html form with all his details like Phone no, e-mail , address etc after the payment is done and successful it updates in database in table named "billing" under 'transaction_status'
Problem is that the mailer script is not able to fetch the user e-mail id from database where the transaction is successful.
And transaction successful status is stored in different table not in one where user details are stored.
the query that should have being used to fetch e-mail id from user who's transaction is successful should be some thing like this
$sql_query="Select email from billing_guest where transaction_status="transaction successful"
This is the mailing script that I used.
$query = "SELECT email FROM billing_guests WHERE email = '" . $_POST["email"] . "'";
$result = mysql_query($query) or die(mysql_error());
$data = mysql_fetch_assoc($result);
$entry = mysql_num_rows($result);
//Check if entry exists
if($entry !== 0){
$message = $data['email'];
$to = "$_POST["email"]" ;
$from = "domain-id";
$Subject = "Hi";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-885n-l\r\n";
$headers .= "From: $from\r\n";
$message .="Thank You";
if(mail($to, $from, $subject, $message, $headers)){
echo 'Email sent';
}else{
echo 'Failed sending email';
}
}else{
echo 'No email entry found';
}
mysql_close($conn);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里有一个合成错误:
将该行更改为
并且邮件函数的参数是
you have a synthax error here:
change that line to
And also the parameters to the mail function are