PHP Contact Form Issue

Hello All!

I can’t seem to get the contact form I’ve put in my website to work. My website contact form is at:

The PHP script I’m using goes as follows:

<?php if ($_POST["email"]<>'') { $ToEmail = ''; $EmailSubject = 'New Patient contact form '; $mailheader = "From: ".$_POST["email"]."\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"]."
"; $MESSAGE_BODY .= "Email: ".$_POST["email"]."
"; $MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"])."
"; mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); ?>

Your message was sent

<?php } else { ?>
    <form action="" method="post"> 
Email address:
Phone Number:
<?php }; ?>

What am I doing wrong here? I tried to use the form action that dream host told me to use… but the contact form isn’t being sent to my email address.

Thank you so much!


I’m glad to see they told you to use their CGI Form Mail service instead of your own script, as yours is vulnerable to being exploited in such way as to allow spam to be sent from your DreamHost account!

So you need to drop the insecure PHP code and just use plain HTML. The instructions for the DreamHost Form Mail service are at:

I haven’t tested the following, I’ve added notes in HTML comments.

<form action="" method="post">
<!-- added recipient field -->
<input type=hidden name="recipient" value="">
<!-- added subject field -->
<input type=hidden name="subject" value="New Patient contact form">
<table width="600" align="center" border="0" cellspacing="2" cellpadding="0">
<td width="29%" class="bodytext">Name:</td>
<!-- changed field name to 'realname' per DreamHost FormMail instructions -->
<td width="71%"><input name="realname" type="text" id="name" size="60"></td>
<td class="bodytext">Email address:</td>
<td><input name="email" type="text" id="email" size="60"></td>
<td class="bodytext">Phone Number:</td>
<!-- oops, changed this field name to 'phone' from duplicate 'email' -->
<td><input name="phone" type="text" id="phone" size="60"></td>
<td class="bodytext">Comment:</td>
<td><textarea name="comment" cols="60" rows="6" id="comment" class="bodytext"></textarea></td>
<td class="bodytext">&nbsp;</td>
<td align="left" valign="top"><input type="submit" name="Submit" value="Send"></td>

Thank you so so much for your help!!!