Hello! I have a file forma.html in it contains the body of the form + php handler mail.php + css file screen.css. When filling out the form and clicking the "Submit" button, an error occurs. Please help, I do not know what the error is. Thank. File

forma.html <head> <title>Форма</title> <meta http-equiv="content-type" content="text/html;charset=windows-1251" /> <meta http-equiv="imagetoolbar" content="no" /> <link rel="stylesheet" href="css/screen.css" media="screen" /> </head> <body> <div id="container"> <h1>Форма обратной связи</h1> <form id="form1" action="mail.php" method="post"> <fieldset><legend>Контактная форма</legend> <p class="first"> <label for="name">Ваше имя</label> <input type="text" name="name" id="name" size="30" /> </p> <p> <label for="email">Ваш Email</label> <input type="text" name="email" id="email" size="30" /> </p> <p> <label for="tel">Ваш телефон</label> <input type="text" name="tel" id="tel" size="30" /> </p> </fieldset> <fieldset> <p> <label for="mess">Сообщение</label> <textarea name="mess" id="mess" cols="30" rows="10"></textarea> </p> </fieldset> <p class="submit"><button type="submit">Отправить</button></p> </form> </div> </body> </html> Файл mail.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251"/> <title>Обратная связь</title> </head> <body> <?php if (isset($_POST['name'])) {$name = $_POST['name'];} if (isset($_POST['email'])) {$email = $_POST['email'];} if (isset($_POST['mess'])) {$mess = $_POST['mess'];} if (empty($name)) { echo "<b>Не указано имя!<p>"; echo "<a href=contacts.html>Вернуться к заполнению формы</a>"; exit; } if (empty($email)) { echo "<b>Не указан e-mail!<p>"; echo "<a href=contacts.html>Вернуться к заполнению формы</a>"; exit; } if (empty($mess)) { echo "<b>Сообщение не написано!<p>"; echo "<a href=contacts.html>Вернуться к заполнению формы</a>"; exit; } $to = "моя почта@ya.ru"; $headers = "Content-type: text/plain; charset = windows-1251"; $subject = "Сообщение с вашего сайта"; $message = "Имя пославшего: $name \nЭлектронный адрес: $email \nСообщение: $mess"; $send = mail ($to, $subject, $message, $headers); if ($send == 'true') { echo "<b>Спасибо за отправку вашего сообщения!<p>"; echo "<a href=index.html>Нажмите,</a> чтобы вернуться на главную страницу"; } else { echo "<p><b>Ошибка. Сообщение не отправлено!"; } ?> </body> </html> Файл css @charset "utf-8"; body{ background:#f8f8f8; font:13px Trebuchet MS, Arial, Helvetica, Sans-Serif; color:#333; line-height:160%; margin:0; padding:0; text-align:center; } h1{ font-size:200%; font-weight:normal; } h2, h3, h4, h5, h6{ font-weight:normal; margin:1em 0; } h2{ font-size:160%; } h3{ font-size:140%; } h4{ font-size:120%; } a{ text-decoration:none; color:#f30; } a:hover{ color:#999; } table, input, textarea, select, li{ font:100% Trebuchet MS, Arial, Helvetica, Sans-Serif; line-height:160%; color:#333; } p, blockquote, ul, ol, form{ margin:1em 0; } blockquote{ } img{ border:none; } hr{ display:none; } table{ margin:1em 0; width:100%; border-collapse:collapse; } th, td{ padding:2px 5px; } th{ text-align:left; } li{ display:list-item; } #container{ margin:0 auto; background:#fff; width:600px; padding:20px 40px; text-align:left; } #form1{ margin:1em 0; padding-top:10px; background:url(../images/form/form_top.gif) no-repeat 0 0; } #form1 fieldset{ margin:0; padding:0; border:none; float:left; display:inline; width:260px; margin-left:25px; } #form1 legend{display:none;} #form1 p{margin:.5em 0;} #form1 label{display:block;} #form1 input, #form1 textarea{ width:252px; border:1px solid #ddd; background:#fff url(../images/form/form_input.gif) repeat-x; padding:3px; } #form1 textarea{ height:125px; overflow:auto; } #form1 p.submit{ clear:both; background:url(../images/form/form_bottom.gif) no-repeat 0 100%; padding:0 25px 20px 25px; margin:0; text-align:right; } #form1 button{ width:150px; height:37px; line-height:37px; border:none; background:url(../images/form/form_button.gif) no-repeat 0 0; color:#fff; cursor:pointer; text-align:center; } При нажатии на кнопку отправить вылезает следующая ошибка Не указано имя! "; $send_error = 1; } if (empty($email)) { echo "Не указан e-mail! "; $send_error = 1; else { if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { echo "E-mail указан не верно! "; $send_error = 1; } } if (empty($mess)) { echo "Сообщение не написано! "; $send_error = 1; } else { if($send_error == 1) { echo "Вернуться к заполнению формы"; } else { $to = "mail@example.ru"; $subject = "Сообщение с сайта"; $message = "Имя пославшего: $name \n\nЭлектронный адрес: $email \n\nСообщение: $mess"; $headers = "Content-type: text/plain; charset = utf-8\r\n"; $headers .= "From: $name <$email>\r\n"; $send = mail ($to, $subject, $message, $headers); if ($send == 'true') { echo "Спасибо за отправку вашего сообщения!"; echo "Нажмите, чтобы вернуться на главную страницу"; } else { echo "Ошибка. Сообщение не отправлено! "; } } } ?> 
  • four
    Wow, even if the error was quoted. And correct the design, blood gushing from the eyes. - meboban
  • Copy the full text of the error. I am fine. - andreyqin
  • one
    Here the CSS sheet is the most necessary, as without it ... mail() returns an error, probably? With localhost under windows? - user6550
  • one
    Read and delve into: phpfaq.ru/debug Answers to all your questions are there - what doesn't work and how to understand it. It is not necessary to ask "whether my syntax is correct", it is necessary to find out on my own. - user6550
  • one
    You have not read this text. Otherwise, at least this would be postponed in the head:> Having received an error message, you can read it and correct it. If you did not do it, write to the forum. In doing so, COPY the error message, - user6550

3 answers 3

The output of the error that you specified cannot display the above handler.

"$ send_error = 1;" I don’t see it in the code at all.

Based on the same conclusion, exit, die, and other constructions are not used.

 <telepatemode> Проверьте расстановку ковычек. </telepatemode> 

    You are in the EXIT checks on DIE () replace and in the course it will work. because logically, you give an error (missing data) and continue the execution of the script.

    • One more. Do you know what is the difference between exit and die? - etki

    And you can not bathe and create a feedback form in the form designer https://www.testograf.ru/ru/ Read more about how to create a feedback form https://www.testograf.ru/ru/blog/forma- obratnoj-svyazi.html

    • Please try to publish detailed answers containing a specific example of the minimum solution, supplementing them with a link to the source. Answers –references (as well as comments) do not add knowledge to the Runet. - Nicolas Chabanovsky