HTML PHP Контактная форма — Отправить и отправить сообщение

Надеюсь, что вы можете помочь, я пытаюсь создать контактную форму для моего сайта, которая представляет собой HTML, стилизованный под CSS и письмо, отправленное с помощью PHP.

Веб-сайт: Эван Чиниелло

Проблема первая: когда сообщение отправляется через контактную форму, оно не перенаправляется и не обновляется (заканчивается на www.evanciniello.ca/php/submit.php)

Проблема вторая: тело сообщения само по себе не отображается в папке «Входящие» (т. Е. Я могу видеть, кто отправил электронное письмо, но не может прочитать сообщение).

Контактная форма HTML

<div id="container" class="clearfix">
<div class="element  clearfix col2-3 contact">
<form id="contact-us" action="/php/submit.php" method="post">
<h1>Contact Us!</h1>
<input type="text" name="first_name" placeholder="NAME" required>
<input  type="email" name="email" placeholder="MAIL" required>
<textarea name="message" placeholder="MESSAGE" required ></textarea>
<input id="button" type="submit" class="submit"></button>
</form>
<div id="error" style="display:none;"> Please Provide Valid Information</div>
</div>
</div>

Форма PHP

<?php
if(isset($_POST['submit'])) {
$to =  "contact@evanciniello.ca";
$subject = "Form Tutorial";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";
$success = mail($to, $subject, $body);
}
?>

-2

Решение

Это нормально. В вашем /php/submit.php

if (isset($_POST['submit'])) {
if (empty($_POST["message"]) || empty($_POST["first_name"]) || empty($_POST["email"])) {
//Set up some error messages here and show that to the users.
} else {
$to = "contact@evanciniello.ca";
$subject = "Form Tutorial";
$name_field = $_POST['first_name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";
$success = mail($to, $subject, $body);
if ($succes) {
//Now we need to redirect
$url = "http://www.evanciniello.ca/WHEREYOUWANTTOREDIRECT";
Header("Location: " . $url);
} else {
//Set up error message, that message can not be setn
die("Message can not be sent");
}

}
}

Добавить name представить:

<input id="button" type="submit" class="submit" name="submit"></button>
2

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector