Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing variable in email message

Status
Not open for further replies.

alsaffar

Programmer
Oct 25, 2001
165
0
0
KW
Hi there,

I managed to make a page that I can fill some fields to send an HTML message and its working fantastic EXCEPT one thing :(

I can't include a variable inside the message, see my page's code:

<?
if ($HTTP_SERVER_VARS['REQUEST_METHOD'] != 'POST')
{
?>
<form method=&quot;post&quot; action=&quot;<? echo $_SERVER[PHP_SELF] ?>&quot;>
Subject <input name=&quot;Subject&quot;><br>
Message <textarea dir=&quot;ltr&quot; name=&quot;Message&quot; cols=&quot;60&quot; rows=&quot;20&quot;></textarea><br>
SendTo <input name=&quot;SendTo&quot;><br>
<input type=&quot;submit&quot;>
</form>
<?
}
else
{
$headers = &quot;MIME-Version: 1.0\r\n&quot;;
$headers .= &quot;Content-Type: text/html; charset=iso-8859\r\n&quot;;
$headers .= &quot;From: MyName <MyName@MyDomain.com>\r\n&quot;;

//Filter the message
$Message = str_replace(chr(34) , &quot;&quot;, $HTTP_POST_VARS[Message]);
$Message = str_replace(chr(92) , &quot;&quot;, $Message);

$Code = &quot;ABCD1234&quot;;

//Send Emails
$MailValue = @mail($HTTP_POST_VARS[SendTo],$HTTP_POST_VARS[Subject],$Message,$headers);
echo &quot;[$MailValue]&quot;;
}
?>

I want the variable $Code to be sent with the message.

Lets say the message is as follows:

<html>
<a href=&quot; . $Code . '&quot;>Click Here</a>
</html>

The variable $Code is not subistuted with its value ABCD1234

Whats wrong?
 
Have u assigend $code to $message..?
Not sure if thsi is the cause..
Code:
$Code = &quot;ABCD1234&quot;;// get the variable
$Message .= $Code ;// form the message

--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
As far as I can tell, you're only giving the variable 'code' value, then doing nothing with it. I would just do what spookie said, except try it like this:

$Message .= &quot;\n\n<a href= here</a>&quot;;

That way it doesn't look out of place to the reciver.

P.S. To cut back on code, you can replace $HTTP_POST_VARS[] with just $_POST[]
 
Just try to execute the code I gave, then in the message text area try to submit the variable $Code and see if it goes correctly or not!

My example was to enter the following in the text area field:

<html>
<a href=&quot; . $Code . '&quot;>Click Here</a>
</html>

and see if it reached the receiver correct or not.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top