K
K
kensei322018-02-21 16:59:03
PHP
kensei32, 2018-02-21 16:59:03

Set up a feedback form?

Greetings to all, I really need help. In the index file, the feedback form has the following code

<!-- form -->
                <form id="contactusform" action="/contact.php" method="post">
                    <div id="alert" class="zero-lr-margin"></div>
                    <div class="col-md-6 col-sm-12 text-center center-col xs-margin-btm-ten">
                        <input name="cf_name" type="text" placeholder="Name" />
                        <input name="cf_email" type="text" placeholder="Email" />
                        <textarea name="cf_message" placeholder="Tell us about your big day"></textarea>
                        <input id="btn-contact" name="send" type="button" value="send message" class="margin-top-zero btn btn-black zero-margin-lr"> </div>
                </form>
                <!-- end form -->

file contact.php code
<?php
$field_name = $_POST['cf_name'];
$field_email = $_POST['cf_email'];
$field_message = $_POST['cf_message'];

$mail_to = '[email protected]вв';
$subject = 'Message from a site visitor '.$field_name;

$body_message = 'From: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Message: '.$field_message;

$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";

$mail_status = mail($mail_to, $subject, $body_message, $headers);

if ($mail_status) { ?>
  <script language="javascript" type="text/javascript">
    alert('Thank you for the message. We will contact you shortly.');
    window.location = 'contact_page.html';
  </script>
<?php
}
else { ?>
  <script language="javascript" type="text/javascript">
    alert('Message failed. Please, send an email to [email protected]');
    window.location = 'contact_page.html';
  </script>
<?php
}
?>

I press the send button, nothing happens ... maybe I need to add something?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Ainur Valiev, 2018-02-22
@vaajnur

need input type="submit"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question