PHP Contact Form Issue

software development

#1

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: http://aer1.co.cc/contact.php

The PHP script I’m using goes as follows:

<?php if ($_POST["email"]<>'') { $ToEmail = 'jeniseparris@gmail.com'; $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="http://formmail.dreamhost.com/cgi-bin/formmail.cgi" method="post"> 
Name:
Email address:
Phone Number:
Comment:
 
<?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!

A


#2

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: http://formmail.dreamhost.com/

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

<form action="http://formmail.dreamhost.com/cgi-bin/formmail.cgi" method="post">
<!-- added recipient field -->
<input type=hidden name="recipient" value="jeniseparris@gmail.com">
<!-- added subject field -->
<input type=hidden name="subject" value="New Patient contact form">
<table width="600" align="center" border="0" cellspacing="2" cellpadding="0">
<tr>
<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>
</tr>
<tr>
<td class="bodytext">Email address:</td>
<td><input name="email" type="text" id="email" size="60"></td>
</tr>
<tr>
<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>
</tr>
<tr>
<td class="bodytext">Comment:</td>
<td><textarea name="comment" cols="60" rows="6" id="comment" class="bodytext"></textarea></td>
</tr>
<tr>
<td class="bodytext">&nbsp;</td>
<td align="left" valign="top"><input type="submit" name="Submit" value="Send"></td>
</tr>
</table>
</form> 

#3

Thank you so so much for your help!!!