PHP mail to, help?

Hi,
I’m trying to find a solution to my php contact form. It seems I cannot get the form to send to my email address and I need some help please.

This is my contact form:-

<h3>Drop a line</h3>

				&lt;form action="#" id="contact_form"&gt;

					&lt;input type="text" id="name" value="Your name" /&gt;

					&lt;input type="email" id="email" value="Your e-mail" /&gt;

					&lt;div class="clearfix"&gt;&lt;/div&gt;

					&lt;div class="textarea"&gt;&lt;textarea cols="30" id="comment" rows="10"&gt;&lt;/textarea&gt;&lt;/div&gt;

					&lt;input type="submit" value="Submit" /&gt;

					&lt;span class="status"&gt;&lt;/span&gt;

				&lt;/form&gt;
                                    &lt;script src="js/script.js"&gt;&lt;/script&gt;

and this is the php within script.js:-

/* Contact form */
$(‘#contact_form’).submit(function () {
$.ajax({
type: ‘POST’,
url: ‘contact.php’,
data: {
name: $(‘#contact_form input[type=text]’).val(),
email: $(“#contact_form input[type=email]”).val(),
text: $(“#contact_form textarea”).val()
},
success: function(data) {
if ( data == ‘sent’ ) {
$(‘#contact_form .status’).html(‘Your message is sent!’);
} else if ( data == ‘invalid’ ) {
$(‘#contact_form .status’).html(‘Your name, email or message is invalid.’);
} else {
$(‘#contact_form .status’).html(‘Your message could not be sent.’);
}
},
error: function () {
$(‘#contact_form .status’).html(‘Your message could not be sent.’);
}
});
return false;
});

What do I need in contact.php in order to have the form information sent to my email address?

[URL=“http://www.w3schools.com/php/func_mail_mail.asp”]http://www.w3schools.com/php/func_mail_mail.asp

refer this for mail function. just get your email address and pass that to the mail function

Contact.php:-

<?php
$to = “MY EMAIL ADDRESS HERE”;
?>

It does not work, it displays “Your message could not be sent.”
Sorry but PHP isn’t my forte, any other ideas?

did you use the same example like in w3 schools ?

Yea, but I don’t need the rest such as:

subject = “My subject”;
$txt = “Hello world!”;
$headers = “From: webmaster@example.com” . "\r
" .
“CC: somebodyelse@example.com”;

etc, I only need a php with my email address.

can you tell what you want to do? post your code so better to guide.

use the required field and try with that.

This seems to work:

<?php

// Enter your e-mail address.
$to = ‘example@example.com’;

// Go to your-site.com/contact.php?test to send a testing email.
if ( isset($_GET[‘test’]) ) {
mail($to, ‘Message from contact form’, 'It\‘s working!’, 'From: ’ . $to . "\r
");
die(‘Testing e-mail has been sent.’);
}

function isValidEmail( $email = null )
{
return preg_match( “/^
[\d\w\/+!=#|$?%{^&}'~-] [\\d\\w\\/\\.+!=#|$?%{^&}*'~-]@
[A-Z0-9]
[A-Z0-9.-]{0,61}
[A-Z0-9]\.
[A-Z]{2,6}$/ix”, $email );
}

if ( !empty($_POST[‘name’]) && isValidEmail($_POST[‘email’]) && !empty($_POST[‘text’])) {

$message = $_POST['text'];
$headers = 'From: ' . $_POST['name'] . ' &lt;' . $_POST['email'] . '&gt;' . "\\r\

" . 'Reply-To: ’ . $_POST[‘email’];

if ( mail($to, 'Message from contact form', $message, $headers) ) echo 'sent';

} else {
echo ‘invalid’;
}

I need a action.php file for this:

<form action=“action.php” method=“post”>
<input type=“text” name=“name” value=“Name” class=“placeholder” />
<input type=“text” name=“email” value=“E-mail” class=“placeholder” />
<textarea name=“message” class=“placeholder”>Message</textarea>
<div class=“status”>email was sent<br/>successfully</div>
<div class=“button mouse-events”><div>Send email</div></div>
</form>

Any ideas?