Hello. I just started to learn PHP, this is a bit over my head yet...
I have the PHPList app installed for my mailing list and I would like to send my new subscribers to a custom thank you page.
there seems to be a lot my people doing this, but I haven't found anyone who is kind enough to help me accomplish this; all I've been getting is lot of incomplete answers. And now I am here.
anyhow, here's what i've got thus far... here is a snippet from the subscribelib2.php file which is where the redirect takes place after a visitor subscibes to one of my lists:
# personalise the thank you page
if ($subscribepagedata["thankyoupage"]) {
$thankyoupage = $subscribepagedata["thankyoupage"];
} else {
$thankyoupage = '<h3>'.$strThanks.'</h3>'. $strEmailConfirmation;
}
if (eregi("\[email\]",$thankyoupage,$regs))
$thankyoupage = eregi_replace("\[email\]",$email,$thankyoupage);
$user_att = getUserAttributeValues($email);
while (list($att_name,$att_value) = each ($user_att)) {
if (eregi("\[".$att_name."\]",$thankyoupage,$regs))
$thankyoupage = eregi_replace("\[".$att_name."\]",$att_value,$thankyoupage);
}
if (is_array($GLOBALS["plugins"])) {
reset($GLOBALS["plugins"]);
foreach ($GLOBALS["plugins"] as $name => $plugin) {
$thankyoupage = $plugin->parseThankyou($id,$userid,$thankyoupage);
}
}
$blacklisted = isBlackListed($email);
if ($blacklisted) {
$thankyoupage .= '<p>'.$GLOBALS["strYouAreBlacklisted"].'</p>';
return 1;
}
if ($sendrequest && $listsok) { #is_array($_POST["list"])) {
if (sendMail($email, getConfig("subscribesubject:$id"), $subscribemessage,system_messageheaders($email),$envelope,1)) {
sendAdminCopy("Lists subscription","\n".$email . " has subscribed\n\n$history_entry");
addUserHistory($email,$history_subject,$history_entry);
print $thankyoupage;
} else {
print '<h3>'.$strEmailFailed.'</h3>';
if ($blacklisted) {
print '<p>'.$GLOBALS["strYouAreBlacklisted"].'</p>';
}
}
} else {
print $thankyoupage;
if ($_SESSION["adminloggedin"]) {
print "<p>User has been added and confirmed</p>";
}
}
print "<P>".$PoweredBy.'</p>';
print $subscribepagedata["footer"];
I have this snippet of code that I think will do the trick, but I'm not sure where to put it nor do I know how to call it from the form after the user has subscribed:
function redirect($url) {
if (!headers_sent()) {
//If headers not sent yet... then do php redirect
header('Location: '.$url); exit;
} else {
//If headers are sent... do javascript redirect... if javascript disabled, do html redirect.
echo '<script type="text/javascript">';
echo 'window.location.href="'.$url.'";';
echo '</script>';
echo '<noscript>';
echo '<meta http-equiv="refresh" content="0;url='.$url.'" />';
echo '</noscript>'; exit;
}
}
If anyone would be willing to help me it would be greatly appreciated.
Thanks a bunch.
Brian