Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-16-2008, 04:44 AM   PM User | #1
nojo191
New Coder

 
Join Date: Jul 2007
Location: Kansas
Posts: 72
Thanks: 3
Thanked 0 Times in 0 Posts
nojo191 is an unknown quantity at this point
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>
__________________
~Nojo191
Noah Benham's website

Last edited by nojo191; 08-16-2008 at 05:31 AM.. Reason: email removal
nojo191 is offline   Reply With Quote
Old 08-16-2008, 05:11 AM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Old 08-16-2008, 05:30 AM   PM User | #3
nojo191
New Coder

 
Join Date: Jul 2007
Location: Kansas
Posts: 72
Thanks: 3
Thanked 0 Times in 0 Posts
nojo191 is an unknown quantity at this point
oh wow that was so easy but so important. thanks sooo much! i never would've figured that out on my own.
__________________
~Nojo191
Noah Benham's website
nojo191 is offline   Reply With Quote
Reply

Bookmarks

Tags
mail, message, php, php headers, variables

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:18 PM.


Advertisement
Log in to turn off these ads.