0

現在、HTML入力フィールド(電子メール)の内容をwelcome@domain.comアドレスに送信する以下のコードがあります。今悩んでいることが二つあります。次のコードを無駄に使用しました-

$to = "welcome@domain.com";
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";

mail($to,$email_subject,$email_body,$headers);
//done. redirect to thank-you page.
header('Location: thankyou.html');
  1. welcome@domain.com からの電子メール応答を自動的に送信するにはどうすればよいですか?

  2. 「お問い合わせいただきありがとうございます。まもなくご連絡いたします」というページの代わりに、domain.com/thankyou.html にリダイレクトする方法はありますか?

これは、正常に動作しているように見える残りのコードです! これについて何か提案があれば、いつでも大歓迎です!

if(isset($_POST['email'])) {

$email_to = "welcome@domain.com";
$email_subject = "Your spot has been saved!";
function died($error) {


echo "We are very sorry, but there were error(s) found with the form your submitted";
echo "These errors appear below<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors<br /><br />";
die();
}


if(
!isset($_POST['email'])
) {
died("We are sorry, but there appears to be a problem with the form your submitted!");
}
$email_from = $_POST['email']; 
$error_message = "";
$email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
if(!eregi($email_exp,$email_from)) {
$error_message .= "The Email Address you entered does not appear to be valid!<br />";
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= 'Email: '.clean_string($email_from)."\n";

$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
Thank you for contacting us. We will be in touch with you very soon.
<?
}
?>
4

1 に答える 1

0

リダイレクトされないページについては、この投稿を参照してくださいstackoverflow.com/questions/6396813/php-header-not-redirecting基本的に、ヘッダー呼び出しの前にストリームに値を出力してはならないことを示しています。

メールの問題については、どのようなエラーが発生しているかを詳しく説明してください。

于 2012-09-17T17:24:15.473 に答える