My PHP contact form keeps giving error -


following code of contact form. fields ok not sending mail , gives error message "error sending message". checked samplemail.php file this link , working well, if use same code website replacing values, doesn't work.

index.html

<form id="contact-valid-form" class="form-style" action="contact.php" method="post" role="form">     <div class="form-group">         <input type="text" class="text-field form-control field-validation required" data-validation-type="string" id="form-name" placeholder="full name" name="name" />         <i class="form-icon fa fa-user"></i>     </div>      <div class="form-group">         <input type="text" class="text-field form-control field-validation required" data-validation-type="email" id="form-email" placeholder="email address" name="email" />     <i class="form-icon fa fa-envelope"></i>     </div>      <div class="form-group">         <textarea placeholder="message..." class="form-control field-validation required" name="message"></textarea>         <i class="form-icon fa fa-comment"></i>     </div>      <div class="form-group submit">         <span class="form-loader"><i class="fa fa-spinner fa-spin"></i></span>         <input type="submit" name="submit" value="submit" class="btn btn-default" />     </div>    </form> 

in contact.php

<?php if (isset($_post['name'],$_post['email'],$_post['message'])){  $name = $_post['name']; $email = $_post['email']; $message = $_post['message']; $from = 'from: ' . $_post['email'];  $to  = 'myemail@mail.com';  $subject = 'subject';   $body = "from: $name\n e-mail: $email\nmessage:\n $message"; if ($name != '' && $email != '' && $message != '') {          if (mail ($to, $subject, $body, $from)) {          echo '<p>success</p>';     } else {          echo '<p>error sending message</p>';      }    } else {     echo '<p>fill form</p>'; } } ?> 

the generic error message not adding more information. can please add below code in else part ? should provide last failure.

if (mail ($to, $subject, $body, $from)) {      echo '<p>success</p>'; } else {      print_r(error_get_last());  }  

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -