Here is a basic one. No user input has been sanitized though. You'll need to add security to it now. Never trust user input.
HTML to match. Here is the example HTML for $email.
Code:
<input type="text" name="email" value="Email" />
Code:
<?php
$email=$_POST['email'];
$name =$_POST['name'];
$message = $_POST['message'];
$subject = $_POST['subject'];
$from = "emailaddressthatitisbeingsentto@mail.com";
$send = mail($from , $subject , "Someone wants to contact you through your website.\n\nThe user who wants to is. \n\nUser: ".$name."\nEmail: ".$email."\n\n".$message."\n\nYour welcome", "FROM: donotrespond@website.com");
if ($send||isset($send)||!empty($send))
{
header('Location: http://www.sitehere.com/page?mail=sent');
} else if(!$send||empty($send)||!isset($send)) {
header('Location: http://www.sitehere.com/page?error=true');
}
?>
You'll need to setup an email account with your domain. Make sure it matches what is put in the script
.
Bookmarks