chomick Posted October 10, 2007 Share Posted October 10, 2007 I have a contact form, which has a subject field (the subject of the email that is sent to me), and when the form is submitted, the subject is not being sent. Instead, I just get a blank subject. Here is the code-- <?php // Configuration Start \\ $YourEmail = "email@email.com"; // Configuration End \\ if($Submit) { if(empty($email) || empty($name) || empty($subject) ||empty($message)) { echo "You forgot to enter some required fields. Please go back and try again."; } elseif(!eregi('^([._a-z0-9-]+[._a-z0-9-]*)@(([a-z0-9-]+\.)*([a-z0-9-]+)(\.[a-z]{2,3})?)$', $email)) { echo "The e-mail is not valid. Please go back and try again."; } else { $Message = "$name has contacted you using your online form. The message is below.\n\n***************\n$message\n***************\n\nIP of sender: $_SERVER[REMOTE_ADDR]\nName of sender: $name\nE-mail of sender: $email\nPhone number of sender: $phone"; $headers = 'From: ' . $email . "\r\n" . 'Reply-To: ' . $email . "\r\n" . 'Subject: ' . $subject . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($YourEmail, $Subject, stripslashes($Message), $headers); echo "Your message has been sent and you will receive a reply shortly. Thank you for your inquiry."; } } else { echo 'Please use the following form to contact me. I will be in touch with you as soon as possible.<br> <br> Fields marked with an asterisk (<font color="#CCCCCC">*</font>) are required.<br> <br><form name="cf" method="post" action=""> <table width="283" border="0" cellpadding="2" cellspacing="1" class="content"> <tr> <td width="2%" align="right" valign="middle"><strong><font color="#CCCCCC">*</font></strong></td> <td width="27%"><strong>Name:</strong></td> <td width="71%"><input name="name" type="text" size="30"></td> </tr> <tr> <td> </td> <td><strong>Phone:</strong></td> <td><input name="phone" type="text" size="20"></td> </tr> <tr> <td align="right" valign="middle"><strong><font color="#CCCCCC">*</font></strong></td> <td><strong>Email:</strong></td> <td><input name="email" type="text" size="30"></td> </tr> <tr> <td align="right" valign="middle"><strong><font color="#CCCCCC">*</font></strong></td> <td><strong>Subject:</strong></td> <td><input name="subject" type="text" size="30"></td> </tr> <tr> <td align="right" valign="middle"><strong><font color="#CCCCCC">*</font></strong></td> <td><strong>Message:</strong></td> <td><textarea name="message" cols="28" rows="10"></textarea></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Send Message"><input type="hidden" name="config" value="0"></td> </tr> </table> </form>'; } ?> Any help would be greatly appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/72628-solved-php-contact-form-blank-subject-when-form-is-sent/ Share on other sites More sharing options...
pocobueno1388 Posted October 10, 2007 Share Posted October 10, 2007 Try to use a lowercase 's' with the $subject variable. That is the way you have it in your form. mail($YourEmail, $subject, stripslashes($Message), $headers); Quote Link to comment https://forums.phpfreaks.com/topic/72628-solved-php-contact-form-blank-subject-when-form-is-sent/#findComment-366174 Share on other sites More sharing options...
chomick Posted October 10, 2007 Author Share Posted October 10, 2007 Yes, that was it! Thank you for your help! Quote Link to comment https://forums.phpfreaks.com/topic/72628-solved-php-contact-form-blank-subject-when-form-is-sent/#findComment-366175 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.