Okay, the way the script is designed, someone goes to http://www.poultryyouth.com/index.php or somewhere else on the site where there is a form to join the ezine. Visitors fill in the form, press "subscribe" and the form sends the data to subscribed.php. The script part of subscribed.php is below:
<?
function makeRandomPassword() {
$salt = "abchefghjkmnpqrstuvwxyz0123456789";
srand((double)microtime()*1000000);
$i = 0;
while ($i <= 7) {
$num = rand() % 33;
$tmp = substr($salt, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}
$code = makeRandomPassword();
?>
<? $date = date("d. M. Y."); ?>
<? $active = ("0"); ?>
<?
include ("config.php");
$insertquery = "INSERT INTO $emailtable (name, email, code, date, active) VALUES ('$name',
'$email', '$code', '$date', '$active')";
$insertresult = mysql_query($insertquery);
if($insertresult == 1)
{
?>
You have successfully subscribed to the PYA's Ezine.<p>
<p>Go back to the last page by clicking <a href="javascript:history.go(-1)">Here</a>
<?
}
else
{
?>
Something went wrong while entering your email address into the database. Please make sure that you entered the correct name and email address and <a href="javascript:history.go(-1)">try again</a>. If you continue having problems, please contact the administrator at <a href="mailto:<?echo $mailinglist_administrator;?>"><?echo $mailinglist_administrator;?></a>.<p>
<?
}
?>
<?
$recipient = ("$email");
$subject = ("Confirmation Email");
$msg = ("Thank you for subscribing to the PYA's free Poultry Ezine. To confirm your subscription, please go to [url]http://www.poultryyouth.com/poultry-ezine/confirm.php?code=[/url]$code If you did not subscribe to the PYA's mailing list, please ignore this email and accept our apologies. Thank you.
You subscribed as $name $email on $date");
$mailheaders = ("From: Poultry Youth of America \n Reply-To: [email]someone@poultryyouth.com[/email]\n\n");
mail($recipient, $subject, $msg, $mailheaders);
?>
As you can see, subscribed.php generates a random code, puts the name, email, code, and date into the database, and sends a confirmation email to the subscriber with a url that contains the code in it. The url is in "http://www.poultryyouth.com/poultry-ezine/confirm.php?asdf" format. Confirm.php is below:
<? include("/config.php"); ?>
<?
$code = $_REQUEST['code'];
if(isset($code))
{
if(mysql_query("SELECT * FROM maileremail WHERE code='$code'"))
{
mysql_query("UPDATE maileremail SET active = '1' WHERE code = '$code'");
echo "Thank you for confirming, you are now added to the list";
}
else
{
echo "You have the wrong code or id, please double check";
}
}
else
{
echo "Please use the link in email to confirm your subscription";
};
?>
Confirm.php is supposed to change "active" to 1. I think that this is where I am running into trouble with this script. I am currently getting the "You have the wrong code or id, please double check" error message.
Any help appreciated...