V
V
vasRmba2018-02-06 00:55:18
PHP
vasRmba, 2018-02-06 00:55:18

Why is the contact form not working?

Tell me what is the error, the simplest form does not work, I'm testing on hosting.

<div id="myModal" class="modal fade">
            <div class="modal-dialog">
                <div class="modal-content">
                  <div class="modal-header">
                    <form id="main-contact-form" action="mail.php" method="POST" class="row form-horizontal form-wizzard">
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <input type="text" name="name" class="form-control" placeholder="Ваше имя ..."/>
                    </div>
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <input type="tel" name="tel" class="form-control" required="required" placeholder="Ваш телефон ..."/>
                    </div>
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                      <textarea rows="3" name="message" class="form-control" placeholder="..."></textarea>
                    </div>
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 text-right">
                      <input type="submit" value="Заказать" class="btn btn-default" style="width: 100%;" />
                    </div>
                  </form>
                    </div>
                  
                </div>
            </div>
        </div>

<?php
$name       = @trim(stripslashes($_POST['name'])); 
$from       = @trim(stripslashes($_POST['tel'])); 
$subject    = @trim(stripslashes($_POST['subject'])); 
$message    = @trim(stripslashes($_POST['message'])); 
$to   		= 'почта@yandex.ru';//replace with your email

$headers   = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/html; charset=utf-8";
$headers[] = "From: {$name} <{$from}>";
$headers[] = "Reply-To: <{$from}>";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion();

mail($to, $subject, $message, $headers);

die;

I put my mail accordingly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Ainur Valiev, 2018-02-06
@vasRmba

corny headers should not be an array but a string
$headers = implode('' , $headers);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question