我的表单有5个步骤,每个步骤都正常,会话变量传递给每个页面。提交后,我希望数据通过电子邮件发送回管理员。我试着写这个,但它返回500错误或白屏。请更正我在这里错了。以下是提交后的电子邮件处理代码。
<?php
session_start();
$email_from = 'no-reply@indianvisaservice.org';//<== update the email address
$email_subject = "New Form submission";
$email_body = "You have received a new message from the user $_SESSION['givenname']."\r\n";.
"Here is the message:\n $message"
$message = Application Reference No - $_SESSION['appid'] ."\r\n";
$message .= type of VISA Application - $_SESSION['visatype']."\r\n";
$message .= Port of Arrival - $_SESSION['arrivalport']."\r\n";
$message .= Application type - $_SESSION['appltype']."\r\n";
$message .= Applicant Name - $_SESSION['givenname']."\r\n";
$message .= Applicant Sex - $_SESSION['applsex']."\r\n";
$message .= Applicant Marital Status - $_SESSION['martstat']."\r\n";
$message .= Applicant Birthdate - $_SESSION['birthdate']."\r\n";
$message .= Applicant Passport No - $_SESSION['passportno']."\r\n";
$message .= Country of Birth - $_SESSION['countrybrth'] ."\r\n";
$message .= Religion of Applicant - $_SESSION['religionxx']."\r\n";
$message .= Educational Qualification - $_SESSION['edu_id']."\r\n";
$message .= Application Nationality by - $_SESSION['nationality_by']."\r\n";
$message .= Passport Issue Place - $_SESSION['issueplace'] ."\r\n";
$message .= Passport Issue date - $_SESSION['issuedate']."\r\n";
$message .= Visual Identification - $_SESSION['visual_d_mark']."\r\n";
$message .= is there Other Passport have - $_SESSION['tab']."\r\n";
$message. = Other Passport No - $_SESSION['oth_ppt_no'] ."\r\n";
$message .= Other Passport Issue Place - $_SESSION['oth_ppt_issue_place']."\r\n";
$message .= Other Passport Issue Date - $_SESSION['previssuedate']."\r\n";
$message .= Other Passport Nationality - $_SESSION['oth_ppt_nationality']."\r\n";
$message .= Other Passport Country Issue - $_SESSION['country_issue'] ."\r\n";
$message .= Father Name - $_SESSION['fthrname']."\r\n";
$message .= Father Nationality - $_SESSION['fathr_nation_id'] ."\r\n";
$message .= Father Previous Nationality - $_SESSION['fthrprevntl']."\r\n";
$message .= Father Place of Birth - $_SESSION['fthrpob']."\r\n";
$message .= Father City of Birth - $_SESSION['fthrcob']."\r\n";
$message .= Mother Name - $_SESSION['mthrname'] ."\r\n";
$message .= Mother Nationality - $_SESSION['mthr_nation_id']."\r\n";
$message .= Mother Previous Nationality - $_SESSION['mthrprevntl']."\r\n";
$message .= Mother Place of Birth - $_SESSION['mthrpob']."\r\n";
$message .= Mother City of Birth - $_SESSION['mthrcob']."\r\n";
$message .= Duration of Visit - $_SESSION['visitduration']."\r\n";
$message .= No of Visa Entry - $_SESSION['visa_entry_id']."\r\n";
$message .= Port of Exit from Country - $_SESSION['exitpointxx']."\r\n";
$message .= Places Likely to be Visit - $_SESSION['placelikelyvisited']."\r\n";
$message .= Places Likely to be Visit2 - $_SESSION['Placelikelyvisited2']."\r\n";
$message .= Do you have Old Visa - $_SESSION['oldvisa']."\r\n";
$message .= Old Visa Number - $_SESSION['old_visa_no']."\r\n";
$message .= Old Visa Type - $_SESSION['old_visa_type_id']."\r\n";
$message .= Old Visa Issue Place - $_SESSION['oldvisaissueplace']."\r\n";
$message .= Permanent Stay - $_SESSION['permStay']."\r\n";
$message. = Refuse Details - $_SESSION['refuse_details']."\r\n";
$message .= Country Visited - $_SESSION['country_visited']."\r\n";
$message .= Name of Referance - $_SESSION['nameofsponsor_ind']."\r\n";
$message .= Referance Address - $_SESSION['referanceaddress']."\r\n";
$message .= Referance City - $_SESSION['referancecity']."\r\n";
$to = "mailme@imgrv.in";//<== update the email address
$headers = "From: $email_from \r\n";
//Send the email!
mail($to,$email_subject,$email_body,$headers,$message);
//done. redirect to thank-you page.
header('Location: thank-you.html');
?>
答案 0 :(得分:3)
使用正确的连接方式 喜欢:
$test ="abc";
echo $email_body = "You have received a new message from the user".$test."\r\n";
答案 1 :(得分:1)
在此文件的开头添加error_reporting(E_ALL); ini_set('display_errors', 1);
。您可以看到语法错误。您错误地添加了" "
进行连接。
答案 2 :(得分:1)
试试这个
<?php
session_start();
$email_from = 'no-reply@indianvisaservice.org';//<== update the email address
$email_subject = "New Form submission";
$message = "Application Reference No - ".$_SESSION['appid']." \r\n";
$message .= "type of VISA Application - ".$_SESSION['visatype']."\r\n";
$message .= "Port of Arrival - ".$_SESSION['arrivalport']."\r\n";
// Concatenate all message like this
$email_body = "You have received a new message from the user". $_SESSION['givenname']."\r\nHere is the message:\n $message";
$to = "mailme@imgrv.in";//<== update the email address
$headers = "From: $email_from \r\n";
//Send the email!
mail($to,$email_subject,$email_body,$headers);
//done. redirect to thank-you page.
header('Location: thank-you.html');
?>
答案 3 :(得分:0)
几点:
在<t t-set="result" t-value="0" />
<t foreach="o.pack_operation_ids" t-as="pack" >
<t t-set="result" t-value="result + sum([x for x in pack.pack_lot_ids.mapped('qty')])" />
</t>
<t t-esc="result" />
变量下面写下这一行,$message
尚未定义。
$message
在邮件功能中,我不确定您为什么要传递$email_body = "You have received a new message from the user ".$_SESSION['givenname']."\r\n" .
"Here is the message:\n $message"; //not sure you made typo here but it should be like this. remove semicolon before dot because you are doing string concatenation.
变量,最后一个参数是用于附加参数Click here for more info
所以它应该是:
$message
希望这对你有所帮助。