Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11

Thread: sendmail bugs

  1. #1
    psy
    psy is offline
    New Coder
    Join Date
    Jul 2011
    Posts
    17
    Thanks
    1
    Thanked 0 Times in 0 Posts

    sendmail bugs

    Hi everyone. I'm a newb to PHP, and I'm tinkering with a sendmail form that I am using as a dummy quote submission. I keep getting blank emails back, however. Can someone please help me out with fixing this code?

    Here's my form (ignore the poor formatting):

    Code:
        <form method="post" action="sendmail.php">
          &nbsp;
          <div align="left">
            <table border="0" width="46%">
              <tr>
                <td valign="top" align="center" colspan="2">
                  <strong><font size="4">Contact Information</font></strong>
                </td>
              </tr>
              <tr>
                <td valign="top" align="right">
                  Your Name:
                </td>
                <td valign="top">
                  <input name="Name" type="text" />
                </td>
              </tr>
              <tr>
                <td valign="top" align="right">
                  Artist:
                </td>
                <td valign="top">
                  <input name="Artist" type="text" size="20" />
                </td>
              </tr>
              <tr>
                <td valign="top" align="right">
                  Your Email:
                </td>
                <td valign="top">
                  <input name="Email" type="text" size="20" />
                </td>
              </tr>
              <tr>
                <td valign="top" align="right">
                  Home:
                </td>
                <td valign="top">
                  <input name="Homepage" type="text" />
                </td>
              </tr>
              <tr>
                <td valign="top" align="right">
                  &nbsp;
                </td>
                <td valign="top">
                  &nbsp;
                </td>
              </tr>
              <tr>
                <td valign="top" align="center" colspan="2">
                  <strong><font size="4">Number 1</font></strong>
                </td>
              </tr>
              <tr>
                <td valign="top" align="right">
                  How many?
                </td>
                <td valign="top">
                  <input name="number" type="text" size="5" /> (approximately)
                </td>
              </tr>
              <tr>
                <td valign="top" height="84" align="right">
                  do you require delivery?
                </td>
                <td valign="top" height="84">
                  <input type="checkbox" name="delivery" value=
                  "Yes" />Yes<br />
                  <input type="checkbox" name="delivery" value=
                  "No" />No<br />
                  <input type="checkbox" name="delivery" value="Owned" />i'll come pick it up<br />
                </td>
              </tr>
              <tr>
                <td valign="top" height="57" align="right">
                  If yes, which would you prefer?
                </td>
                <td valign="top" height="57">
                  <input type="checkbox" name="car" value=
                  "paid" />1 (paid)<br />
                  <input type="checkbox" name="car" value=
                  "free" />2 (free)
                </td>
              </tr>
              <tr>
                <td valign="top" height="60" align="right">
                  Do you require a....
                </td>
                <td valign="top" height="60">
                  <input type="checkbox" name="fridge" value=
                  "Yes" />Yes<br />
                  <input type="checkbox" name="fridge" value="No" />No
                </td>
              </tr>
              <tr>
                <td valign="top" height="67" align="right">
                  Are you a qualified technician?
                  </td>
                <td valign="top" height="67">
                  <input type="checkbox" name="personal" value=
                  "Yes" />Yes<br />
                  <input type="checkbox" name="personal" value="No" />No
                </td>
              </tr>
              <tr>
                <td valign="top" align="right">
                  Do you require regular maintenance?
                </td>
                <td valign="top">
                  <input type="checkbox" name="maintenance" value=
                  "Yes" />Yes<br />
                  <input type="checkbox" name="maintenance" value="No" />No
                </td>
              </tr>
              <tr>
                <td valign="top" align="right">
                  Any other extra requirements:
                </td>
                <td valign="top">
                  <textarea rows="9" name="other" cols="36">
    </textarea>
                </td>
              </tr>
              <tr>
                <td valign="top">
                  &nbsp;
                </td>
                <td valign="top">
                  &nbsp;
                </td>
              </tr>
              <tr>
                <td valign="top">
                  How do you find out about us
                </td>
                <td valign="top">
                  <input name="foundthrough" type="text" />
                </td>
              </tr>
            </table>
          </div>
          <p align="left">
            <br />
            <input type="submit" /> <input type="reset" value="Reset"
            name="B1" />
          </p>
          <p align="left">
            Please allow 48 hours for a response.
          </p>
        </form>
    And here's my sendmail PHP:

    Code:
    <?php
      $name = $_REQUEST['name'] ;
      $artist = $_REQUEST['artist'] ;
      $email = $_REQUEST['email'] ;
      $homepage = $_REQUEST['homepage'] ;
      $number = $_REQUEST['number'] ;
      $delivery = $_REQUEST['delivery'] ;
      $car = $_REQUEST['car'] ;
      $fridge = $_REQUEST['fridge'] ;
      $personal = $_REQUEST['personal'] ;
      $maintenance = $_REQUEST['maintenance'] ;
      $other = $_REQUEST['other'] ;
      $foundthrough = $_REQUEST['foundthrough'] ;
    
      mail( "myemail@email.com", "Quote",
        $message, "From: $email" );
      header( "Location: thankyou.php" );
    ?>
    Sorry if this is a stupid/amateur question. I think it has something to do with the sendmail.

    Thanks to anyone who can help!

  • #2
    Regular Coder
    Join Date
    Jul 2010
    Posts
    271
    Thanks
    3
    Thanked 40 Times in 40 Posts
    Your fieldnames all start with caps in the form but not in the request
    If you can't stand behind your troops, feel free to stand in front of them
    Semper Fidelis

  • #3
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,332
    Thanks
    60
    Thanked 526 Times in 513 Posts
    Blog Entries
    4
    Quote Originally Posted by psy View Post

    And here's my sendmail PHP:

    Code:
    <?php
      $name = $_REQUEST['name'] ;
      $artist = $_REQUEST['artist'] ;
      $email = $_REQUEST['email'] ;
      $homepage = $_REQUEST['homepage'] ;
      $number = $_REQUEST['number'] ;
      $delivery = $_REQUEST['delivery'] ;
      $car = $_REQUEST['car'] ;
      $fridge = $_REQUEST['fridge'] ;
      $personal = $_REQUEST['personal'] ;
      $maintenance = $_REQUEST['maintenance'] ;
      $other = $_REQUEST['other'] ;
      $foundthrough = $_REQUEST['foundthrough'] ;
    
      mail( "myemail@email.com", "Quote",
        $message, "From: $email" );
      header( "Location: thankyou.php" );
    ?>
    You're using the $message variable as the email content but where has it been set? - I only see $message in your mail() function and no where else. Therefore I assume $message is null and therefore you will not see anything in your email.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #4
    psy
    psy is offline
    New Coder
    Join Date
    Jul 2011
    Posts
    17
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Yes I just noticed that. Should I change that to mail( "myemail@email.com", "Quote",
    $name, $email... etc?

  • #5
    Regular Coder
    Join Date
    Jul 2010
    Posts
    271
    Thanks
    3
    Thanked 40 Times in 40 Posts
    Hell, Tangoforce guess I didnt have enough coffee earlier missed that lol
    If you can't stand behind your troops, feel free to stand in front of them
    Semper Fidelis

  • #6
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,332
    Thanks
    60
    Thanked 526 Times in 513 Posts
    Blog Entries
    4
    Quote Originally Posted by psy View Post
    Yes I just noticed that. Should I change that to mail( "myemail@email.com", "Quote",
    $name, $email... etc?
    I wouldn't do that, I would make one variable out of them like this:
    PHP Code:
    $message "Hello $name
    This is to confirm your membership to $site_name.

    You subscribed using email $email.

    Thanks"

    Etc.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #7
    psy
    psy is offline
    New Coder
    Join Date
    Jul 2011
    Posts
    17
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you Tangoforce!

    The contents of this form are going to be sent to my e-mail address. Will the way you wrote above give me the input from both the text and checkbox fields in my form to my email? What changes would I need to make to my sendmail.php?

  • #8
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,332
    Thanks
    60
    Thanked 526 Times in 513 Posts
    Blog Entries
    4
    The code I gave was a sample. You'll have to decide what your email text contains and what variables you put into it
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #9
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,332
    Thanks
    60
    Thanked 526 Times in 513 Posts
    Blog Entries
    4
    Quote Originally Posted by jimhill View Post
    Hell, Tangoforce guess I didnt have enough coffee earlier missed that lol
    LOL

    (PS Sorry must of missed your post yesterday )
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #10
    psy
    psy is offline
    New Coder
    Join Date
    Jul 2011
    Posts
    17
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks a lot tangoforce. However now I'm just getting blanks in the sent email instead of the variable input from the form.

    I'm now using this:

    Form:

    Code:
    <form method="post" action="sendmail.php">
      Email: <input name="email" type="text" /><br />
      Message:<br />
      <textarea name="message" rows="15" cols="40">
      </textarea><br />
        Fridges:<br />
      <textarea name="fridges" rows="15" cols="40">
      </textarea><br />
      <input type="submit" />
    </form>
    And the sendmail:

    PHP Code:
    <?php
      $message 
    "Email address is $email. Fridges requested is $fridges.";
      
    $email $_REQUEST['email'] ;
      
    $fridges $_REQUEST['fridges'] ;

      
    mail"email@email.com""Feedback Form Results",
        
    "The Email: $message""Email: $email" );
      
    header"Location: thankyou.php" );
    ?>
    Struggling to get it to work. Sorry for the newb questions. Responses are appreciated.

  • #11
    psy
    psy is offline
    New Coder
    Join Date
    Jul 2011
    Posts
    17
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Fixed it! I had the $message at the start instead of before the other variables. Thanks everyone for the help!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •