I
I
Ivan Nikiforov2021-06-16 16:41:01
PHP
Ivan Nikiforov, 2021-06-16 16:41:01

Why wasn't the letter sent?

There is a feedback form that fully works, displays a message that the letter has been sent. I look, but there is no letter in the mail. Why is that?

<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" href="css/formreg.css">
</head>
    
<form method="post" action="mail.php">
 
   <input type="text" name="login" placeholder=" Введите логин" required>
   <input type="password" name="pass" placeholder="Введите пароль" required>
   <input type="email" name="email" placeholder="Введите почту" required>
   <input type="tel" name="tel" placeholder="Введите телефон">

   <input type="submit" value="Отправить">
 
</form>
</html>


<?php
  $login = $_POST['login'];
  $pass = $_POST['pass'];
  $email = $_POST['email'];
  $tel = $_POST['tel'];

  
  $login = htmlspecialchars($login);
  $pass = htmlspecialchars($pass);
  $email = htmlspecialchars($email);
  $tel = htmlspecialchars($tel);

  $login = urldecode($login);
  $pass = urldecode($pass);
  $email = urldecode($email);
  $tel = urldecode($tel);

  $login = trim($login);
  $pass = trim($pass);
  $email = trim($email);
  $tel = trim($tel);

  if (mail("[email protected]",
           "Новое письмо с сайта",
           "Логин: ".$login."\n".
           "Пароль: ".$pass."\n".
           "Почта: ".$email."\n".
           "Телефон: ".$tel,
           "From: [email protected] \r\n")
  ) {
    echo ('Письмо успешно отправлено!');
  }

  else {
    echo ('Есть ошибки! Проверьте данные...');
  }
  


?>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question