I have this html form:

<form action="post.php" id="form-login" method="POST" class="form-login cf"> <div class="name f_left"> <input type="text" name="first-name" placeholder="FIRST NAME"> </div> <div class="second_name f_left"> <input type="text" name="last-name" placeholder="SECOND NAME"> </div> <div class="country f_left"> <input type="text" name="country" placeholder="COUNTRY"> </div> <div class="phone f_left cf"> <input type="text" class="f_left phone__code" name="code" placeholder="380"> <input type="text" class="f_left phone__number" name="number" placeholder="PHONE"> </div> <div class="email"> <input type="text" name="email" class="email__input" placeholder="E-MAIL"> </div> <div class="submit f_left"> <button name="button" form="form-login" value="Отправить">START NOW!</button> </div> </form> 

And PHP script:

 <? // ----------------------------конфигурация-------------------------- // $adminemail="sn97@inbox.ru"; // e-mail админа $date=date("dmy"); // число.месяц.год $time=date("H:i"); // часы:минуты:секунды //$backurl="http://site.ru/index.html"; // На какую страничку переходит после отправки письма //---------------------------------------------------------------------- // // Принимаем данные с формы $name=$_POST['first-name']; $last_name=$_POST['last-name']; $country=$_POST['country']; $code=$_POST['code']; $number=$_POST['number']; $email=$_POST['email']; $msg=$_POST['message']; // Проверяем валидность e-mail $c = 1; if ($c==2) { echo "<center>Вернитесь <a href='javascript:history.back(1)'><B>назад</B></a>. Вы указали неверные данные!"; } else { $msg=" <p>Имя: $name</p> <p>Фамилия: $last_name</p> <p>Страна: $country</p> <p>Код страны: $code</p> <p>Номер: $number</p> <p>E-mail: $email</p> "; // Отправляем письмо админу mail("$adminemail", "$date $time Сообщение от $name", "$msg"); //Сохраняем в базу данных $f = fopen("message.txt", "a+"); fwrite($f," \n $date $time Сообщение от $name"); fwrite($f,"\n $msg "); fwrite($f,"\n ---------------"); fclose($f); //Выводим сообщение пользователю print "<script language='Javascript'> <!-- function reload() {location = \"$backurl\"}; setTimeout('reload()', 6000); //--></script> $msg <p>Сообщение отправлено! Подождите, сейчас вы будете перенаправлены на главную страницу...</p>"; exit; } ?> 

I am trying to adjust the form, so that it sends the data that I filled in to my mail. When you click the button, it displays inscriptions without data (for example: Name: // empty field) and nothing comes in the mail. I do this for the first time. Help, good people.

thank

    1 answer 1

    Reasons why you can't send mail:

    1) Sendmail is not configured on the local server, or smtp

    2) Mail () function disabled on remote server

    If you use a local server, then you should create a txt file where your letters will be entered (the code that is below the text "// Save to the database" in the post.php file).

    MAMP does not include a mail server. You can use Postfix or an external SMTP server, or install MAMP PRO yourself.

    Below is a description of mail settings in MAMP PRO:

    enter image description here

    Description of SMTP settings for mail.ru: https://help.mail.ru/mail-help/mailer/popsmtp

    • I did not set anything up myself. Just opened Php Storm and from there I opened the html and sent the form. And so, the messages came in the mail, but the fields are empty and they came after 3 hours. Why is that? - Nikita Shchypylov
    • What is your local server? Attach the letter that came in the mail. - Gleb Ostrikov
    • MAMP worth it. <p> Name: </ p> <p> Last Name: </ p> <p> Country: </ p> <p> Country Code: </ p> <p> Number: </ p> <p> E -mail: </ p> - Nikita Shchypylov
    • The message most likely came from me, not from you. Install MAMP PRO to send messages. MAMP does not send mail. - Gleb Ostrikov
    • But I didn’t even include a mump in my work, how did he see it? - Nikita Shchypylov