1
これは初めてのことで、このコードにいくつかの追加機能を追加する方法を理解しようとしています。phpフォーム - リダイレクトとボックスにオプションを追加します
- では、ページを送信、すなわちwww.google.com
- チェックボックスが自動的にチェックする必要があり、クライアントが詳細を電子メールで送信されます際にそれがサブスクリプションのためにFALSE/TRUEを返す必要があります外部のURLにリダイレクトする必要がありますニュースレター
(クライアントは、彼らがでたりしませ選ぶにしたいかどうかを知っているので)これは私のPHPコードです:
<?php
// Enter the email where you want to receive the notification when someone subscribes
$emailTo = '[email protected]';
$subscriber_email = addslashes(trim($_POST['email']));
if (!isEmail($subscriber_email)) {
$array = array('valid' => 0, 'message' => 'Insert a valid email address!');
echo json_encode($array);
} else {
$array = array('valid' => 1, 'message' => 'Thanks for your subscription!');
echo json_encode($array);
// Send email
$subject = 'New Subscriber (Free eBook)!';
$body = "You have a new subscriber!\n\nEmail: " . $subscriber_email;
// uncomment this to set the From and Reply-To emails, then pass the $headers variable to the "mail" function below
// $headers = "From: ".$subscriber_email." <" . $subscriber_email . ">" . "\r\n" . "Reply-To: " . $subscriber_email;
mail($emailTo, $subject, $body);
}
?>
そして、これは私のHTMLです:
<form class="form-inline" role="form" action="assets/subscribe.php" method="post">
<div class="form-group">
<label class="sr-only" for="subscribe-email">Email address</label>
<input type="text" name="email" placeholder="Enter your email..." class="subscribe-email form-control" id="subscribe-email">
</div>
<button type="submit" class="btn">Receive your free eBook</button>
<br>
<div class="checkbox">
<label>
<input type="checkbox" class="checked"> Receive Our Monthly Newsletter
</label>
</div>
</form>
<div class="success-message"></div>
<div class="error-message"></div>
を誰かが無効なメールアドレスを入力しても、リダイレクトされます。else条件の中で 'mail()'の後ろに追加する必要があります。 – Boratzan
@Boratzan質問は「ページをリダイレクトする必要があります」で、「購読の成功でページをリダイレクトする必要はありません。 –
あなたは彼が正しいことを尋ねていないという点を知っていますが、コードでは有効な電子メールアドレスであるかどうかをチェックしています。意味がありません。 – Boratzan