私は今までこのコンタクトフォームで作業していましたが、依然として動作中の電子メールを送信できませんでした。だから私の時間を無駄にする代わりに、私はいくつかの助けを求めるかもしれないと思った別の解決策を推測してチェックします。送信ボタンは電子メールを送信せず、サーバー上でアクションを開始しません。
フォームは次のようになります。でも私contact.phpファイルはそうのように見える
<form action="assets/php/contact.php" name="contact" id="contact" role="form" method="post">
<div class="form-group">
<label class="sr-only" for="name">Name</label>
<input type="text" id="name" class="form-control" name="name" placeholder="Name*" required="" data-validation-required-message="Please enter your name.">
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<label class="sr-only" for="email">Email</label>
<input type="email" id="email" name="email" class="form-control" placeholder="Your E-mail*" required="" data-validation-required-message="Please enter your email address.">
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<label class="sr-only" for="category">Video Category</label>
<input type="text" id="category" class="form-control" name="category" placeholder="Category*" required="" data-validation-required-message="Please enter the catergory.">
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<textarea class="form-control" id="message" name="message" rows="7" placeholder="Message*" required data-validation-required-message="Please enter your message."></textarea>
<p class="help-block text-danger"></p>
</div>
<div class="text-center">
<button type="submit" name="submit" class="btn btn-block btn-round btn-dark">Submit</button>
</div>
</form>
:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$category = $_POST['category'];
$from = 'Contact Form';
$to = '[email protected]';
$body = "From: $name\n Category: $category\n E-Mail: $email\n Message:\n $message";
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from)) {
$result='<div class="alert alert-success">Thank You! I will be in touch</div>';
} else {
$result='<div class="alert alert-danger">Sorry there was an error sending your message. Please try again later</div>';
}
}
?>
現在、私は自分のサイト上で送信ボタンを押したときにページは何もしません。 PHPファイルの404エラーが出る前に、私はそれを修正したようです。
'ボタンに値を割り当てるか、文 – David
がこれです場合は削除if文がない正しい形式? '$ _POST ['submit'] { if(mail to $、$件名、...' –
あなたが知っているはずの非常に基本的なPHP – David