dimanche 22 mars 2015

php email not sending using bootstrap

using theme shuffle in bootstrap. Awesome theme by the way. For three days i have researched and cannot find the answer.


using validator.js plugin


It isn't throwing any error messages at me. on submit, no email and page reloads. Seperate sendform.php.


Here is the form code:



<form id="contact-form" class="wow bounceInUp" data-wow-offset="10" data-wow-delay="0.2s" data-toggle="validator" role="form" method="post" action="sendform.php">
<div class="row marginbot-20">
<div class="col-md-6 xs-marginbot-20">
<label for="inputName" class="control-label"></label>
<input type="text" class="form-control input-lg" id="inputName" placeholder="Enter name" required="required" />
</div>
<div class="col-md-6">
<label for="inputEmail" class"control-label"></label>
input type="email" class="form-control input-lg" id="inputEmail" placeholder="Enter email" required="required" />
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="inputSubject" class="control-label"></label>
<input type="text" class="form-control input-lg" id="inputSubject" placeholder="Subject" required="required" />
</div>
<div class="form-group">
<label for="inputMessage" class="control-label">
<textarea name="message" id="inputMessage" class="form-control" rows="4" cols="25" required placeholder="Message"></textarea>
</div>
<button type="submit" class="btn btn-skin btn-lg btn-block" id="submit">
Send Message</button>
</div>
</div>
</form>


php file is sendform.php



<?php

$mymail = 'myemail@gmail.com';

if (isset($_POST["submit"])) {
$name = $_POST['inputName'];
$email = $_POST['inputEmail'];
$subject = $_POST['inputSubject'];
$message = $_POST['InputMessage'];
$from = $email;
$to = $mymail;
$subject = 'NEW MESSAGE';
$body ="From: $name\n E-Mail: $email\n $subject\n Message:\n $message";


// Check if name has been entered
if (!$_POST['inputName']) {
$errName = 'Please enter your name';
}

// Check if email has been entered and is valid
if (!$_POST['inputEmail'] || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
$errEmail = 'Please enter a valid email address';
}
//Check if subject has been entered
if (!$_POST['inputSubject']) {
$errSubject = 'Please enter your subject';
}
//Check if message has been entered
if (!$_POST['inputMessage']) {
$errMessage = 'Please enter your message';
}

// If there are no errors, send the email
if (!$errName && !$errEmail && !$errSubject && !$errMessage) {
if (mail ($to, $subject, $body, $from)) {
{header( "Location: thankyou.html" );}
} else {
{header( "Location: index.html" );}
}
}
}
?>


so i cannot submit form without the correct input which is great. on submit the page reloads and in address bar shows url finishing in .com/?message='with what was input into the message text area'.


no error messages appearing and no email sent to me.


Any help would be greatly appreciated. Go easy on me, im a noob. cheers


Aucun commentaire:

Enregistrer un commentaire