0
これを行う方法についていくつかの記事を読んでいますが、ある時点で私のコードは正常に機能していましたが、もう機能しません。ユーザーが送信すると、エラー、または
bがあった場合、それはPHPヘッダーがサブミット後にリダイレクトされない
a)は、彼らに警告モーダルを与える必要があります)thankyou.phpページへの再直接彼らにヘッダを使用しています。それはもはやこれをしません。
エラーなしでフォームを送信した後、ページは空白になるようにリロードされ、urlにはまだourpeachwedding.com/#rsvpと表示されます。それはあなたのフォームの設定方法thankyou.php.`
<?php
$modalMessage="<p class='lead'>Thank you for visiting our page, and please be sure to <a onclick=$('#myModal').modal('hide') href='#rsvp' >RSVP</a> if you haven't already. If you RSVP'd on our page previous to April 14th, 2017, please do so again, as our email was not recieving messages due to some coding errors. Thank you!</p>";
$modalTitle="Welcome!";
if ($_POST["submit"]) {
if (!$_POST["name"]) {
$error.="<br> Please enter the name on your invitation.";
$nameError="<p class='inlineError'>Please enter the name on the invitation.</p>";
}
if (!$_POST["head-count"]) {
$error.="<br> Please enter the size of your party.";
$headCountError="<p class='inlineError'>Please enter the size of your party.</p>";
}
if (!$_POST["attending"]) {
$error.="<br> Please let us know if you will be able to make it or not.";
$attendingError="<p class='inlineError'>Please let us know if you will be able to make it or not.</p>";
}
if (!$_POST["reception-check"]) {
$error.="<br> Please let us know if you will be attending the reception.";
$receptionCheckError="<p class='inlineError'>Please let us know if you will be attending the reception.</p>";
}
if ($error) {
$result='<div class="alert alert-danger"><strong>There were errors in your form.</strong>'.$error.'</div>';
$modalMessage = $result;
$modalTitle = "Sorry! Looks like there was a mistake, please fill in the entire form.";
} else {
if (mail("[email protected]", "RSVP", "
Name: ".$_POST['name']."
Head Count: ".$_POST['head-count']."
Attending?: ".$_POST['attending']."
Reception Check: ".$_POST['reception-check']."
Comments: ".$_POST['comments'])) {
header('Location: http://www.ourpeachwedding.com/pages/thankyou.php');
exit();
} else {
$result='<div class="alert alert-danger"><strong>Sorry, there was an error submitting your rsvp, please try again.</strong>'.$error.'</div>';
}
}
}
?>
ログを確認し、可能であればエラー報告を有効にしてください。あなたは "* Headers already sent .. *"エラー、またはそれがリダイレクトされない理由を説明する別のエラーを見つける可能性があります。 – Qirel
@Qirel php.iniでエラー報告を有効にしましたが、投稿時にエラーは表示されません。あなたはourpeachwedding.comのライブサイトで自分でテストすることができます。あなたが私を助けてくれたら、私はそれを感謝します。私のコードは大丈夫ですか? –
ファイルの先頭に 'error_reporting(E_ALL);を追加してください。 ini_set( "display_errors"、1); '' <?php'の直後にあります。 'header()'コールが決して論理的に到達することはありません(そうするための適切な条件は決してありません)。あるいは、コールの前にある種の出力があります。 – Qirel