Hello.
So I downloaded a template and I’m really bad at PHP.
My problem is I don’t know what to change for it so send it to my email.
This is my form in the HTML
<script type="text/javascript" src="js/form-validation.js"></script>
<form id="contactForm" action="#" method="post">
<fieldset>
<p>
<label>NAMN:</label>
<input name="name" id="name" type="text" />
</p>
<p>
<label>EMAIL:</label>
<input name="email" id="email" type="text" />
</p>
<p>
<label>ÄRENDE:</label>
<input name="web" id="web" type="text" />
</p>
<p>
<label>MEDDELANDE</label>
<textarea name="comments" id="comments" rows="5" cols="20" ></textarea>
</p>
<!-- send mail configuration -->
<input type="hidden" value="kvnwpts@hotmail.com" name="to" id="to" />
<input type="hidden" value="kvnwpts@hotmail.com" name="from" id="from" />
<input type="hidden" value="From torn wordpress online" name="subject" id="subject" />
<input type="hidden" value="send-mail.php" name="sendMailUrl" id="sendMailUrl" />
<!-- ENDS send mail configuration -->
<p><input type="button" value="SKICKA" name="submit" id="submit" /></p>
</fieldset>
<p id="error" class="warning">Message</p>
</form>
<p id="success" class="success">Tack för ditt meddelande.</p>
<!-- ENDS form -->
This is the form validation js.
$(document).ready(function(){
// hide messages
$("#error").hide();
$("#success").hide();
// on submit...
$("#contactForm #submit").click(function() {
$("#error").hide();
//required:
//name
var name = $("input#name").val();
if(name == ""){
$("#error").fadeIn().text("Name required.");
$("input#name").focus();
return false;
}
// email
var email = $("input#email").val();
if(email == ""){
$("#error").fadeIn().text("Email required");
$("input#email").focus();
return false;
}
// web
var web = $("input#web").val();
if(web == ""){
$("#error").fadeIn().text("Web required");
$("input#web").focus();
return false;
}
// comments
var comments = $("#comments").val();
// send mail php
var sendMailUrl = $("#sendMailUrl").val();
//to, from & subject
var to = $("#to").val();
var from = $("#from").val();
var subject = $("#subject").val();
// data string
var dataString = 'name='+ name
+ '&email=' + email
+ '&web=' + web
+ '&comments=' + comments
+ '&to=' + to
+ '&from=' + from
+ '&subject=' + subject;
// ajax
$.ajax({
type:"POST",
url: sendMailUrl,
data: dataString,
success: success()
});
});
// on success...
function success(){
$("#success").fadeIn();
$("#contactForm").fadeOut();
}
return false;
});
This is the send mail.php
<?php
//vars
$subject = $_POST['subject'];
$to = explode(',', $_POST['to'] );
$from = $_POST['email'];
//data
$msg = "NAME: " .$_POST['name'] ."<br>\
";
$msg .= "EMAIL: " .$_POST['email'] ."<br>\
";
$msg .= "WEBSITE: " .$_POST['web'] ."<br>\
";
$msg .= "COMMENTS: " .$_POST['comments'] ."<br>\
";
//Headers
$headers = "MIME-Version: 1.0\\r\
";
$headers .= "Content-type: text/html; charset=UTF-8\\r\
";
$headers .= "From: <".$from. ">" ;
//send for each mail
foreach($to as $mail){
mail($mail, $subject, $msg, $headers);
}
?>
So. What am I gona change for it to send it to my email?