Dean,
I'm getting to this at last. I have:
1) installed the .php file configured for my site
www.clickbasics.com/mail/tell-a-friend.php2) linked to it from an e-mail newslwtter
<p><a href="
http://www.clickbasics.com/mail/tell-a-friend.php?u=!uid">Share this newsletter with a friend.</a></p>
However, when I test it with a real user (me)
http://www.clickbasics.com/mail/tell-a-friend.php?u=33912bdafter adding a test name and e-mail addres (again, me" Paul Carter, paulc@clickbasics.com) the query does not find me as the user. On hitting the "Submit" button, I get the message: "User not found."
I checked the table "lm_user" and the user record is fine. I suspect the problem is in the following query:
list($curFirst,$curLast,$curEmail)=@mysql_fetch_row(mysql_query("select fname,lname,email from $utable where uid = '".addslashes($u)."';"));
if(!$curFirst) exit('User not found');
Please advise.
My full code follows.
Paul C.
----------
<?php
///mail/tell-a-friend.php
//created 12/12/2007
//modified 5/19/2008
// Connect to ListMail DB / Initialize
include('./config.php');
include('./admin.php');
// Submit Processing
$friendName = $_POST['friendName'];
$friendEmail = $_POST['friendEmail'];
if (isset($_POST['Submit']))
{
if(!$friendName){
echo "Please enter your friend’s name.<br />";
} elseif(!$friendEmail){
echo "Please enter your friend’s email address.<br />";
//} elseif(!valid_email($friendEmail)){
} elseif(!$friendEmail){
echo "Please enter a valid friend email address.<br />";
} else {
//all ok, get current user info from ListMail
list($curFirst,$curLast,$curEmail)=@mysql_fetch_row(mysql_query("select fname,lname,email from $utable where uid = '".addslashes($u)."';"));
if(!$curFirst) exit('User not found');
$sendName = "ClickBasics";
$sendEmail = "service@clickbasics.com";
$subject = "Greetings, $friendName - $curFirst wants you to check this out";
$message = "A friend sent you this.";
mail($friendEmail,$subject,$message,"Return-path: <$sendEmail>\n
From: \'$sendName\' <$sendEmail>");
}
}
// Main page
?>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1" />
<title>Tell a Friend</title>
</head>
<html>
<head>
<title>Tell a Friend</title>
</head>
<body><form method=post action=./tell-a-friend.php>
<input type="hidden" name="submitted" value="1">
Your friend’s name: <input type="text" name="friendName"><br />
Your friend’s e-mail: <input type="text" name="friendEmail"><br />
<input type="submit" name="Submit" id="Submit" value="Submit" class="btn" />
</form>
</body>
</html>