Skip navigation
tonyb1117
Currently Being Moderated

why is my php form not sending to my e-mail?

Mar 20, 2013 7:18 PM

Tags: #error #php #html #dreamweaver #html5 #cs6 #contact_page

Here i have the code for my .php document and the code for my html. Why is the form not sending to my e-mail (browna.shu@gmail.com)? At one point I had the form sending to my e-mail, but the information that was filled out was not appearing. Now no email is being sent at all. I tried a contact-us.php page with the php email code in the same document and now have the information in seperate documents, but I am getting the same results every which way. I need help I have been checking this over for hours and looking up solutions online but it all is very confusing. PLEASE HELP!

 

 

send.php

 

<?php

 

 

if ($_POST['parse_var'] == "contactForm") {

 

          $emailTitle = 'Scheduele In Home Consultation or General Question';

          $yourEmail = 'browna.shu@gmail.com';

 

          $firstName = $_POST['FirstName'];

          $lastName = $_POST['LastName'];

          $phoneNumber = $_POST['PhoneNumber'];

          $emailAddress = $_POST['EmailAddress'];

          $Message = $_POST['Message'];

 

          $body = <<<EOD

<br><hr><br>

          First Name: $firstName <br />

          Last Name: $lastName <br />

          Phone Number: $phoneNumber <br />

          Email Address: $emailAddress <br />

          Message: $Message <br />

 

EOD;

 

          $headers = "From: $emailAddress\r\n";

          $headers .= "Content-type: text/html\r\n";

          $success = mail("$yourEmail", "$emailTitle", "$body", "$headers");

 

          $sent = "Thank you! Your message has been sent.";

}

 

 

?>

 

 

 

 

 

 

 

contact-us.html

 

 

      <form action="send.php" method="post" name="contactForm" id="contactForm">

        <table width="75%" align="left" cellpadding="5" id="contactustable">

          <tr>

            <td><label for="FirstName"></label>

              <span id="sprytextfield1">

              First Name<br>

              <br>

              <input type="text" name="FirstName" id="FirstName" value="<?php print "$firstName"; ?>">

            <span class="textfieldRequiredMsg">Please enter your first name.</span></span></td>

          </tr>

          <tr>

            <td> </td>

          </tr>

          <tr>

            <td><label for="LastName"></label>

              <span id="sprytextfield2">

              Last Name<br>

              <br>

              <input type="text" name="LastName" id="LastName" value="<?php print "$lastName"; ?>">

            <span class="textfieldRequiredMsg">Please enter your last name.</span></span></td>

          </tr>

          <tr>

            <td> </td>

          </tr>

          <tr>

            <td><label for="PhoneNumber"></label>

              <span id="sprytextfield3">

              Phone Number<br>

              <br>

              <input type="text" name="PhoneNumber" id="PhoneNumber" value="<?php print "$phoneNumber"; ?>">

<span class="textfieldInvalidFormatMsg">Please enter your phone number.</span></span></td>

          </tr>

          <tr>

            <td> </td>

          </tr>

          <tr>

            <td><label for="EmailAddress"></label>

              <span id="sprytextfield4">E-mail Address<br>

              <br>

              <input type="text" name="EmailAddress" id="EmailAddress" value="<?php print "$emailAddress"; ?>">

            <span class="textfieldRequiredMsg">Please enter your e-mail address.</span><span class="textfieldInvalidFormatMsg">Example: myemail@email.com.</span></span></td>

          </tr>

          <tr>

            <td> </td>

          </tr>

          <tr>

            <td height="255"><label for="Message"></label>

              <span id="sprytextarea1">

              Message:<br>

              <br>

              <textarea name="Message" cols="85%" rows="12" id="Message"><?php print "$Message"; ?></textarea>

            <span class="textareaRequiredMsg">A value is required.</span></span></td>

          </tr>

          <tr>

            <td> </td>

          </tr>

          <tr>

            <td><input type="submit" name="Reset" id="Reset" value="Reset">

              <input type="hidden" name="parse_var" id="parse_var">             

            <input type="submit" name="Submit" id="Submit" value="Send Message"></td>

          </tr>

          <tr>

            <td><?php print "$sent"; ?></td>

          </tr>

        </table>

      </form>

 
Replies
  • Currently Being Moderated
    Mar 20, 2013 11:43 PM   in reply to tonyb1117

    What is this all about?

    if ($_POST['parse_var'] == "contactForm") {

     

    You don't have a form field named 'parse_var' with a value of contactForm. What were you trying to do here?

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 21, 2013 12:56 AM   in reply to tonyb1117

    If you are seperating the form and the processing script into two individual files then you don't need:

     

    if ($_POST['parse_var'] == "contactForm") {

     

    OR

     

    the closing curly bracket after the $sent variable and before the closing ?> php tag:

     

    $sent = "Thank you! Your message has been sent.";

     

    }

     

    ?>

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 21, 2013 6:21 AM   in reply to tonyb1117

    tonyb1117 wrote:

     

    It works! Thank you very much for pointing that out "bregent" and "osgood_". I have one more small problem though, when signing out my contact form the phone number field does not accept any phone number?

     

                  <input type="text" name="PhoneNumber" id="PhoneNumber" value="<?php print "$phoneNumber"; ?>">

    <span class="textfieldInvalidFormatMsg">Please enter your phone number.</span></span></td>

     

    Any solutions?

     

     

     

    I don't know anything about Spry validation of form fields but I think it requires you to set the type of validation, i.e., text, email, number.

     

    Have you looked in that direction.

     

    I presume what youre saying is when you hit send you get a red message saying phone number is not valid or something along those lines?

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 21, 2013 6:26 AM   in reply to osgood_

    I don't see any Spry tagging of that field, though, so like you I am curious what is meant by "the phone number field does not accept any phone number?".

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 21, 2013 6:38 AM   in reply to MurraySummers

    The OP has only posted a snip of the form field:

     

    <td><label for="PhoneNumber"></label>

                  <span id="sprytextfield3">

                  Phone Number<br>

                  <br>

                  <input type="text" name="PhoneNumber" id="PhoneNumber" value="<?php print "$phoneNumber"; ?>">

    <span class="textfieldInvalidFormatMsg">Please enter your phone number.</span></span></td>

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 21, 2013 6:52 AM   in reply to osgood_

    Oh, right.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points