Jump to content

[SOLVED] PHP contact form--blank subject when form is sent


chomick

Recommended Posts

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.