•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 423,610 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,189 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 766 | Replies: 2 | Solved
![]() |
•
•
Join Date: Dec 2006
Location: Texas
Posts: 29
Reputation:
Rep Power: 0
Solved Threads: 0
I have a php email form that is giving me greif. It is sending blank messages. Could anyone take a look at the code and help. It would be greatly appreciated.
contact.php
sendmail.php
contact.php
<script LANGUAGE="JavaScript">
function Validate(form)
{
if (form.name.value == "")
{ alert("Please insert your name"); form.name.focus(); return; }
if (form.email.value == "")
{ alert("Please insert your E-mail"); form.email.focus(); return; }
if (form.comment.value == "")
{ alert("Please insert your comments or questions"); form.comment.focus(); return; }
if (form.email.value.indexOf('@', 0) == -1 || form.email.value.indexOf('.', 0) == -1)
{ alert("Your email is not valid."); form.email.focus(); return; }
form.submit();
}
</script>
<img src="../images/head_contact.gif" width="230" height="36">
<table width="466" cellpadding="0" cellspacing="5">
<form name="form1" method="post" action="sendmail.php">
<input name="subject" type="hidden" value="Contact Page Comment">
<tr>
<td height="25" colspan="2">Name: </td>
<td height="25" colspan="2"> <input name="name" type="text" class="TEXT" size="40">
</td>
</tr>
<tr>
<td height="25" colspan="2">Email: </td>
<td height="25" colspan="2"> <input name="email" type="text" class="TEXT" size="50"></td>
</tr>
<tr>
<td height="40" colspan="2" valign="top">Comments or Questions: </td>
<td colspan="2"><textarea name="comment" cols="60" rows="5" class="TEXT"></textarea></td>
</tr>
<tr>
<td> </td>
<td height="30" colspan="3" align="center" valign="bottom">
<input type="button" name="Button" value="Submit Comment" class="BUTTON" onClick="Validate(this.form)">
</td>
</tr>
</form>
</table>
sendmail.php
<img src="../images/head_contact.gif" width="230" height="36">
<table width="466" cellpadding="0" cellspacing="5">
<tr>
<td>
<?PHP
//to address
$email_to = "jonathan@jbknowledge.com";
//from address
$headers = 'From: '.$email."\r\n";
//Send mail
mail($email_to,$subject,$comment,$headers);
?>
Thank you for submitting your question! - Click <a href="http://www.askpriscilla.com"> here </a> to go back to the site. </td>
</tr>
</table>
•
•
Join Date: Apr 2005
Location: New York state
Posts: 465
Reputation:
Rep Power: 5
Solved Threads: 72
It's sending empty messages because
Also, you $email in sendmail.php should be replaced with
the same for $subject, it should be changed to
$comment doesn't exist. You can get it by replacing $comment with $_POST['comment'].Also, you $email in sendmail.php should be replaced with
$_POST['email']the same for $subject, it should be changed to
$_POST['subject'] Last edited by ShawnCplus : Sep 17th, 2007 at 6:25 pm.
GCS d- s+:+ a-->? C++(++++) UL+++ P+>+++ L+++ !E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
•
•
Join Date: Dec 2006
Location: Texas
Posts: 29
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
It's sending empty messages because$commentdoesn't exist. You can get it by replacing$commentwith$_POST['comment'].
Also, you $email in sendmail.php should be replaced with$_POST['email']
the same for $subject, it should be changed to$_POST['subject']
That got it working! Thank you very much. It is always fun trying to fix someone elses code...
Jonathan
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Need a contact form (HTML and CSS)
- Need a contact form for my web site (Site Layout and Usability)
- Abuse of a PHP contact script (PHP)
- Abuse Of A Php Contact Script, someone is the bcc to send out emails (PHP)
- Removing pictures from Outlook 2003 Contact form (Windows Software)
- Help With Contact Us Form! (PHP)
- php login form (PHP)
- php mail form - need to redirect to new page (PHP)
- Need Web Based Contact Us Form (PHP)
- I need help with a form please (PHP)
Other Threads in the PHP Forum
- Previous Thread: HTML In Mail
- Next Thread: Conditional - string contains


Linear Mode