我制作了一个表格,以便在我的网站上与我联系。这是php代码:
<?php
$errors = '';
$myemail = 'yourname@website.com';//<-----Put Your email address here.
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['message']))
{
$errors .= "\n Error: all fields are required";
}
$name = $_POST['name'];
$email_address = $_POST['email'];
$message = $_POST['message'];
if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
$email_address))
{
$errors .= "\n Error: Invalid email address";
}
if( empty($errors))
{
$to = $myemail;
$email_subject = "Contact form submission: $name";
$email_body = "You have received a new message. ".
"name: $name \n\n email: $email_address \n\n\n $message";
$headers = "From: $myemail\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
header('Location: contact_thanks.html');
}
?>
当我在网站上使用表格时,我收到一封带有奇怪符号的邮件。那是因为我用希伯来语写的形式是——英文字母传递得很好。当我将“myemail”更改为另一封邮件时,即使在希伯来语中,邮件也能很好地传递,但我希望将邮件传递给第一封邮件。
我更改了很多次编码,但似乎都没有解决问题,也许我还没有尝试过正确的编码。
我不是写代码的人,我对php不太了解,所以请给我容易理解的答案。