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 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2007
    Posts
    72
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question PHP mail variables won't display in message

    Hi, I'm using the following PHP to process a form. When I get emailed with the form results, all the variables within "message" don't display (such as 'IP'). Any ideas on how to fix this? I've been working on it for hours with now luck. Thanks!!!

    PHP Code:
    <?php
    $company 
    $_REQUEST['company'] ;
    $name $_REQUEST['name'] ;
    $phone $_REQUEST['phone'] ;
    $email $_REQUEST['email'] ;
    $subj $_REQUEST['subj'] ;
    $comments $_REQUEST['comments'] ;

    /* Print IP address */
    $ip=@$_SERVER['REMOTE_ADDR'];

    // message
    $message '
    QTS contact submission
    Company $company
    Name $name
    Phone $phone
    Email $email
    IP $ip
    Message
    $comments
    '
    ;

    // Mail it
    mail("[I]*email removed for spam prevention*[/I]""QTS: $subj"$message"From: $email");
    ?>
    The PHP is accessed with the following HTML form:
    Code:
              <form method=post action="contact_submit.php">            
                <table border="0" ALIGN="CENTER" cellpadding="3" cellspacing="0" style='font-family: Tahoma; font-size: 9pt;'>
              <tr align="center" valign="middle">
              <td colspan="2"><em><font size="1">An asterisk <font color="#FF0000">*</font>
    
              indicates a required field</font></em></td>
              </tr>
              <tr>
              <td  align="left">Company Name:</td>
              <td  align="left" valign="middle"> <input type="text" name="company" size="35" style='width: 250px; font-family: Tahoma; font-size: 9pt;'>
              </td>
              </tr>
    
              <tr>
              <td  align="left"><font COLOR="#FF0000" size="2" face="Tahoma, Arial, Helvetica, sans-serif">*</font>Contact
              Name:</td>
              <td  align="left" valign="middle"> <input type="text" name="name" size="35" style='width: 250px; font-family: Tahoma; font-size: 9pt;'>
              </td>
              </tr>
              <tr>
              <td  align="left"><font COLOR="#FF0000" size="2" face="Tahoma, Arial, Helvetica, sans-serif">*</font>Contact
              Phone Number:</td>
    
              <td  align="left" valign="middle"> <input type="text" name="phone" size="35" style='width: 250px; font-family: Tahoma; font-size: 9pt;'>
              </td>
              </tr>
              <tr>
              <td  align="left"><font COLOR="#FF0000" size="2" face="Tahoma, Arial, Helvetica, sans-serif">*</font>&nbsp;Contact
              Email Address:</td>
              <td  align="left" valign="middle"> <input type="text" name="email" size="35" style='width: 250px; font-family: Tahoma; font-size: 9pt;'>
              </td>
    
              </tr>
              <tr>
              <td  align="left">Topic of Inquiry:</td>
              <td  align="left" valign="middle"> <input type="text" name="subj" size="35" style='width: 250px; font-family: Tahoma; font-size: 9pt;'>
              </td>
              </tr>
              <tr>
              <td  align="left" valign="top">Please describe your interest<BR>in our products and services:</td>
    
              <td  align="left" valign="top"> <textarea name="comments" cols="30" rows="8" wrap="VIRTUAL" style='width: 250px; font-family: Tahoma; font-size: 9pt;'></textarea>
              </td>
              </tr>
              <tr>
              <td colspan=2 align=center> <input class="FormLt1" type="submit" value="Submit Contact Form">
              </td>
              </tr>
    
              </table>
              </form>
    Last edited by nojo191; 08-16-2008 at 05:31 AM. Reason: email removal

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Variables wrapped in single quotations are treated as literal strings.
    PHP Code:
    $message '
    QTS contact submission
    Company $company
    Name $name
    Phone $phone
    Email $email
    IP $ip
    Message
    $comments
    '

    Change the ' and ' to " " and it will process the correct fields. You cannot retain linefeeds this way though, you'll need to manually add \n to the message.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    New Coder
    Join Date
    Jul 2007
    Posts
    72
    Thanks
    3
    Thanked 0 Times in 0 Posts
    oh wow that was so easy but so important. thanks sooo much! i never would've figured that out on my own.


  •  

    Tags for this Thread

    Posting Permissions

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