Jump to content

PHP email form


mattrd

Recommended Posts

I can't seem to get my email form to work. yet it seems to work "sometimes" but not sure why, now i can't seem to get it to work at all. here is my code.

 

<?php $title="Contact Me"; ?>
<?php include("includes/header.php"); ?>
<?php 
if ($_POST["email"]<>'') { 
$ToEmail = 'MY-EMAIL-GOES-HERE; 
$EmailSubject = 'Website Contact Form'; 
$mailheader = "From: ".$_POST["name"]."\r\n"; 
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; 
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
$MESSAGE_BODY = "Name: ".$_POST["name"]."<br>"; 
$MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>"; 
$MESSAGE_BODY .= "Comment: ".nl2br($_POST["comments"])."<br>"; 
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); 
?> 
<div id="content">
	<h1>Contact.</h1>
	Your message was sent.
	<?php 
	} else { 

	echo "<div id=\"content\">
	<h1>Contact.</h1>
	<p>Please use the form below to send me an email. I'd love to hear from you!</p>
	<form action=\"contact.php\" method=\"post\">
		<label>Name:</label><br />
		<input class=\"text\" type=\"text\" name=\"name\" /><br />
		<label>Email Address:</label><br />
		<input class=\"text\" type=\"text\" name=\"email\" /><br />
		<label>Comments:</label><br />
		<textarea name=\"comments\" cols=\"60\" rows=\"5\" name=\"comments\"></textarea>
		<br />
		<input type=\"submit\" value=\"Submit\" />
	</form>;"
	?>
</div>
<?php 
}; 
?>
<?php include("includes/footer.php"); ?>

Any help will be greatly appreciated.

(form can be viewed here:) http://www.matthewrdaniels.com/contact.php

 

Thank you!

Link to comment
https://forums.phpfreaks.com/topic/245209-php-email-form/
Share on other sites

    $yourname = "name";
    $youremail = "[email protected]";
    $subject = "you subject title";
    $body = "message you want to send"
    $headers = "MIME-Version: 1.0\n";
    $headers .= "Content-type: text/plain; charset=iso-8859-1\n";
    $headers = "From: $yourname<$youremail>\r\n";
    $headers .= "X-Mailer: PHP's mail() Function\n";


    mail($to, $subject, $body, $headers); 

 

Try this

Link to comment
https://forums.phpfreaks.com/topic/245209-php-email-form/#findComment-1259448
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.