Hello. I have the following script which I like to with this: mysite/emailafriend.php?link=<?=$request_url?>
Here is the code.
<?
$baseURL = "mysite.com"; //site address
$subject = "Check this site out"; //the subject for the e-mails
// Overrides GPC variables if magic_quotes is turned on
if (get_magic_quotes_gpc()) {
for (reset($HTTP_GET_VARS); list($k, $v) = each($HTTP_GET_VARS); )
$$k = stripslashes($v);
for (reset($HTTP_POST_VARS); list($k, $v) = each($HTTP_POST_VARS); )
$$k = stripslashes($v);
for (reset($HTTP_COOKIE_VARS); list($k, $v) = each($HTTP_COOKIE_VARS); )
$$k = stripslashes($v);
}
?>
<head>
<title>E-mail a friend</title>
</head>
<?
if (!$submit) {
include ("mysite/header.html");
?>
<form name="emailform" method="post" action="">
<table width="100%" cellpadding="2" border="0" cellspacing="0" align="center">
<tr>
<td colspan="2" align="center" valign="top">
<h3>Tell a friend about <?=$link?></h3>
</td>
</tr>
<tr>
<td align="right">Your Friend's Name:</td>
<td align="left"><input type=text name="txtFriendName" size="40"></td>
</tr>
<tr>
<td align="right">Your Friend's E-mail address:</td>
<td align="left"><input type=text name="txtFriendEmail" size="40"></td>
</tr>
<tr>
<td align="right">Your Name:</td>
<td align="left"><input type=text name="txtName" size="40"></td>
</tr>
<tr>
<td align="right">Your E-mail address:</td>
<td align="left"><input type=text name="txtEmail" size="40"></td>
</tr>
<tr>
<td colspan="2" align="center">
Comments<br>
<textarea name="txtComments" cols="40" rows="5"></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="hidden" value="<?=$link?>" name="link">
<input type=submit value="Send It!" name="submit">
<input type="reset" name="Reset" value="Reset Form">
</td>
</tr>
</table>
</form>
<?}
else {
if (!preg_match ("/[\w-]+@[\w-]+.[\w-]+/", $txtEmail)) {
$strBadInput = "Your e-mail address is invalid";
}
elseif (!preg_match ("/[\w-]+@[\w-]+.[\w-]+/", $txtFriendEmail)) {
$strBadInput = "The recipient e-mail address is invalid.";
}
elseif (!preg_match ("/[A-Z]/i", $txtName)) {
$strBadInput = "You must supply your name.";
}
elseif (!preg_match ("/[A-Z]/i", $txtFriendName)) {
$strBadInput = "You must supply your friend's name.";
}
if ($strBadInput) {?>
<h2 align="center"><?=$strBadInput?></h2>
<h3 align="center"><a href="?link=<?=$link?>">Please try again.</a></h3>
<?}
else {
$url = $baseURL . $link;
$strBody = "Dear $txtFriendName,\n\nI think this site is really great and think you'd be interested in it as well.\n\n";
$strBody .= "Go to $url.\n\n$txtComments\n\nYour friend,\n$txtName";
mail("$txtFriendName <$txtFriendEmail>",$subject,$strBody,"From:$txtName <$txtEmail>");?>
<h1 align="center">Your message has been sent.</h1>
<h3 align="center"><a href='javascript: history.go(-2)'>Return to site.</a></h3>
<?
}
}
?>
</body>
When I test the scipt, the email that dumps into my box tells me to link to
http://www.mysite.com<?=$request_url?>.
the part that says <?=$request_url?> needs to be the rest of the filepath to the current page. What am I doing wrong?