简体   繁体   English

一个简单的PHP提交表单中的错误

[英]Error in a simple PHP submit form

I hope someone can help me out with this problem I'm facing. 我希望有人可以帮助我解决我面临的这个问题。

I have a simple PHP form which is showing an error I don't know why, here's the code: 我有一个简单的PHP表单,显示了一个我不知道为什么的错误,这是代码:

        <?php

// Get values from form
$name=$_POST['name'];
$email=$_POST['email'];
$emailconfirmation=$_POST['emailconfirmation'];
$phone=$_POST['phone'];
$address=$_POST['address'];
$postcode=$_POST['postcode'];
$eventarea=$_POST['eventarea'];
$typeevent=$_POST['typeevent'];
$eventdate=$_POST['eventdate'];
$guestnumber=$_POST['guestnumber'];
$extraguests=$_POST['extraguests'];
$siteformarquee=$_POST['siteformarquee'];
$seatedorstanding=$_POST['seatedorstanding'];
$dancefloor=$_POST['dancefloor'];
$servicetent=$_POST['servicetent'];
$surfacemarquee=$_POST['surfacemarquee'];
$details=$_POST['details'];
$town=$_POST['town'];




$to = "email@email.com, email2@email.com";
$subject = "Quote to review from Elite Marquees";
$message = " Name: " . $name . "\r\n Town of the Event: " . $town . "\r\n Telephone Number: " . $phone . "\r\n Email: " . $email . "\r\n Confirm Email Address: " . $emailconfirmation . "\r\n Address: " . $address . "\r\n Post Code: " . $postcode . "\r\n The area where your event will take place: " . $eventarea . "\r\n Type of the Event: " . $typeevent . "\r\n Date of the Event: " . $eventdate . "\r\n Number of Guests: " . $guestnumber . "\r\n If a wedding how many extra guests for the evening?: " . $extraguests . "\r\n Town Where the Event will take place: " . $town . "\r\n Do you have a venue or site for the marquee?: " . $siteformarquee . "\r\n Will your guests be seated or standing?: " . $seatedorstanding . "\r\n Do you require a dance floor?: " . $dancefloor . "\r\n Do you require a service tent?: " . $servicetent . "\r\n Type of surface the marquee will be erected on?: " . $surfacemarquee . "\r\n Details or Questions?: " . $details;


/*$from = "Elite Marquees";*/
$headers = "From: Elite Marquees <info@elitemarquees.com>" . "\r\n";
$headers .= "Content-type: text/plain; charset=UTF-8" . "\r\n"; 

if(@mail($to,$subject,$message,$headers))
{
  print "<script>document.location.href='http://elite-marquees.co.uk/success.html';</script>";

}else{
  echo "Error! Please try again.";
}



?>

Live Form 现场表格

Can someone please help me out? 有人可以帮我吗?

Thanks! 谢谢!

Php's Mail Function Return Values: PHP的Mail函数返回值:

Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise. 如果邮件已成功接受传递,则返回TRUE,否则返回FALSE。

It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination. 重要的是要注意,仅仅因为邮件已被接受送达,并不意味着邮件实际上将到达预期的目的地。

Essentially, you mail function is failing. 本质上,您的邮件功能失败。

First, check if you can send a test mail on the server. 首先,检查是否可以在服务器上发送测试邮件。 If you can't the server settings are not configured to use email. 如果不能,则服务器设置未配置为使用电子邮件。

Try and call a really simple, hard-coded mail() . 尝试调用一个非常简单的硬编码mail()

If it is still failing, then it's 99% your server set up. 如果仍然失败,那就是您的服务器设置的99%。 Check your php.ini settings, and make sure your server can support sending out emails. 检查您的php.ini设置,并确保您的服务器可以支持发送电子邮件。

Which error are you getting? 您遇到什么错误? And is your php.ini updated for the following lines? 并且您的php.ini是否针对以下行进行了更新?

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = Your Email ID

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path =/usr/sbin/sendmail

the email you're using as FROM must be on the same server as the website, meaning info@elite-marquees.co.uk would work just fine but not info@elitemarquees.com 您用作FROM的电子邮件必须与网站位于同一服务器上,这意味着info@elite-marquees.co.uk可以正常工作,但info@elitemarquees.com不能正常工作

try adding a fifth parameter to your mail() command: 尝试在您的mail()命令中添加第五个参数:

mail($to,$subject,$message,$headers,"-f info@elitemarquees.com");

Firstly remove the @ before the mail function . 首先在邮件功能之前删除@。 After try again if error occur again and again you must check whats the value are comes for you can use for that var_dump(mail(your mail)) or die; 再次尝试后,如果一次又一次发生错误,则必须检查该值是什么,因为该值可用于该var_dump(mail(your mail))或死亡; function to check the value if it give the null that means something is missing. 函数检查该值是否为null,表示缺少某些内容。 Then again check var_dump for other values you will soon find the error May be that help you . 然后再次检查var_dump中的其他值,您很快就会发现错误,可能对您有所帮助。

The problem was from <info@elitemarquees.com> I changed it to <info@elitemarquees.co.uk> and now it's working. 问题出在<info@elitemarquees.com>我将其更改为<info@elitemarquees.co.uk> ,现在可以正常工作了。

Thanks to all of you guys! 谢谢大家! You rock! 你摇滚!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM