Contact form help

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?

Isn’t there anyone to help me with this? I’ve tried some different ways but It dosen’t work. Some of you who are good at php maybe can figure out what to change for me to get the mail.

Thanks

Firstly, it’s better to use PHP for validation rather than JS. If JS is turned off, you get no validation at all, and you can’t control who has JS on and off. So this form is very insecure, and your server could get bady hacked with a script like this.

At any rate, get the PHP working before you start to introduce JS.

I’m no expert at this, but I can’t see a call to your PHP file in all that code. Normally it would be in the action=“” part of your form. Where is the PHP script located?

Thatnks for taking your time Ralph. But you know I had problem with my Menu. This website was a template I used. I just gona make my own website from scratch. So I don’t need this anymore.

CLOSE THIS THREAD.