Contact form help


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">
										<input name="name"  id="name" type="text" />
										<input name="email"  id="email" type="text" />
										<input name="web"  id="web" type="text" />
										<textarea  name="comments"  id="comments" rows="5" cols="20" ></textarea>
									<!-- send mail configuration -->
									<input type="hidden" value="" name="to" id="to" />
									<input type="hidden" value="" 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>
								<p id="error" class="warning">Message</p>
							<p id="success" class="success">Tack för ditt meddelande.</p>
							<!-- ENDS form -->

This is the form validation js.


	// hide messages 
	// on submit...
	$("#contactForm #submit").click(function() {
		var name = $("input#name").val();
		if(name == ""){
			$("#error").fadeIn().text("Name required.");
			return false;
		// email
		var email = $("input#email").val();
		if(email == ""){
			$("#error").fadeIn().text("Email required");
			return false;
		// web
		var web = $("input#web").val();
		if(web == ""){
			$("#error").fadeIn().text("Web required");
			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
			url: sendMailUrl,
			data: dataString,
			success: success()
	// on success...
	 function success(){
    return false;

This is the send mail.php

$subject = $_POST['subject'];
$to = explode(',', $_POST['to'] );

$from = $_POST['email'];

$msg = "NAME: "  .$_POST['name']    ."<br>\
$msg .= "EMAIL: "  .$_POST['email']    ."<br>\
$msg .= "WEBSITE: "  .$_POST['web']    ."<br>\
$msg .= "COMMENTS: "  .$_POST['comments']    ."<br>\

$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.


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.