Jump to content

Recommended Posts

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

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/150426-phplist-redirect-subscribelib2php/
Share on other sites

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

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;

    }

 

Call that redirect($url) function in this if and erase  print $thankyoupage;

Like this:

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

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);

      redirect("mythankyoupage.php");

    }

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.