I'm not able to find the error in my code. My PHP code is in my index.html file. I'm not able to send messages from my static webpage.
HTML Code:
<div class="col-md-6">
<form action="index.html" method="POST" class="contact-form" role="form">
<input type="text" class="form-control" id="fname" name="fname" placeholder="Your Full Name">
<input type="email" class="form-control" id="email" name="email" placeholder="Your E-mail">
<input type="text" class="form-control" id="subj" name="subj" placeholder="Your Subject">
<textarea id="mssg" name="mssg" placeholder="Your Message" class="form-control" rows="10"></textarea>
<input class="btn btn-main btn-lg" type="submit" id="submit" name="submit" data-loading-text="<i class='fa fa-spinner fa-spin'></i> Sending...">
</form>
</div>
PHP Code:
<?php
if (isset($_POST['submit'])) {
$to = 'email@company.com';
$siteName = 'http://www.website.com';
$name = $_POST['fname'];
$mail = $_POST['email'];
$subject = $_POST['subj'];
$message = $_POST['mssg'];
$mailSub = '[Contact] [' . $siteName . '] '.$subject;
$body = 'Sender Name: ' . $name . "\n\n";
$body .= 'Sender Mail: ' . $mail . "\n\n";
$body .= 'Message Subject: ' . $subject . "\n\n";
$body .= 'Message: ' . $message;
$header = 'From: ' . $mail . "\r\n";
$header .= 'To: ' . $to . "\r\n";
mail($to, $mailSub, $body, $header);
}else{
echo '0';
}
?>
I receive an error every time i try to send a message through my website. Thank you!