F
F
FIKSER2018-03-13 16:06:00
PHP
FIKSER, 2018-03-13 16:06:00

Why is the php form not working on the site?

I made a feedback form with the following code:

spoiler
Send.php
<?php 
 
$sendto   = "[email protected]"; 
$username = $_POST['userpost_name'];   
$usertel = $_POST['userpost_phone'];  


// Тема сообщения
$subject  = "Test!";
$headers  = "From: " . strip_tags($usermail) . "\r\n";
$headers .= "Reply-To: ". strip_tags($usermail) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=UTF-8 \r\n";
 
// Структура сообщения
$msg  = "<html><body style='font-family:Arial,sans-serif;'>";
$msg .= "<h2 style='font-weight:bold;border-bottom:1px dotted #ccc;'>Новый заказ!</h2>\r\n";
$msg .= "<p><strong>ФИО:</strong> ".$username."</p>\r\n";
$msg .= "<p><strong>ТЕЛЕФОН:</strong> ".$usertel."</p>\r\n";


$msg .= "</body></html>";
 
// Результат отправки
if(@mail($sendto, $subject, $msg, $headers)) {
     header("Location: index-2.html");
} else {
    echo "<center><img src='images/ne-tpravleno.png'></center>";
}
 
?>


Everything works fine on the localhost, well, how great it didn’t work for me through the ajax handler and I decided to leave it stupidly with a redirect to the main one. Hosting does not work

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alex-1917, 2018-03-13
@FIKSER

Firstly, uncle, I clumsily made the header of the letter, here is a working example, pay attention to your extra spaces !!!:

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=utf-8\r\n";
$headers .= "From: ".$contact_email."\r\n";

Secondly, forget about glitches for five years already like mail-ru, and even more so Google! Use the box on Yasha! And you won't need any SMTP!!))
Thirdly, check the availability of the mail function, maybe you have already aroused hosters' suspicions with your testing and they disabled this function on your account, this is not a joke, but a real story!

I
imhuman, 2018-03-13
@imhuman

The mail function can be disabled on the hosting, use the full SMTP sending

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question