Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Simple way to check newsletter email addresses

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 01-27-2003, 10:22 AM
 
usermike usermike is offline
 

Advanced Member
  
Join Date: Jan 2003
Posts: 41
 

Default Simple way to check newsletter email addresses

When a user subscribes to the newsletter, in order to prevent people who don't want to be signed up and people who sign other people up, I have coded a way so that the email address be checked before it is added to the newsletter list.

I did this pretty quickly, so if anyone has any improvements, I would be happy to see them Always remember to backup all files before implementing anything in case you miss something.

First, in /customer/home_main.tpl add the following code right after the first if statement:

Code:
{elseif $smarty.get.mode eq "subscribed_ch"} {include file="main/subscribe_confirmation_ch.tpl"}

then make a file called subscribe-ch.php (in the /mail directory) and put the following code in it:

Code:
<? # # $Id: subscribe-ch.php,v 1 2003/1/27 10:59:49 matr Exp $ # require "../smarty.php"; require "../config.php"; require "./func.php"; include "../include/get_language.php"; $email = trim(($email)); if (!is_correct_efunc_send_mail($email)) { header("Location: ../$redirect/error_message.php?subscribe_bad_email"); } else { $result = db_query("select count(*) from $sql_tbl[maillist] where email='$email'"); list($c) = db_fetch_row($result); db_free_result($result); if ($c > 0) { header("Location: ../$redirect/error_message.php?subscribe_exist_email"); } else { //db_query("insert into $sql_tbl[maillist] values('$email', '".time()."')"); # # Send mail notification to customer # $mail_smarty->assign("email",$email); func_send_mail($email, "mail/newsletter_subscribe_subj.tpl", "mail/newsletter_subscribe_ch.tpl", $config["Company"]["newsletter_email"], false); # # Send mail notification to admin # func_send_mail($config["Company"]["newsletter_email"], "mail/newsletter_admin_subj.tpl", "mail/newsletter_admin.tpl", $email, true); header("Location: ../$redirect/home.php?mode=subscribed_ch&email=".urlencode($email)); } } ?>

then add the following template file called subscribe_confirmation_ch.tpl in the skin1/main directory:

Code:
{* $Id: subscribe_confirmation_ch.tpl,v 1 2003/1/27 13:54:57 zorg Exp $ *} { include file="location.tpl" last_location=$lng.lbl_newsletter_subscription} {capture name=dialog} {$lng.txt_newsletter_subscription_msg_ch} {$smarty.get.email} {/capture} { include file="dialog.tpl" title=$lng.txt_thankyou_for_subscribing content=$smarty.capture.dialog extra="width=100%"}

note the creation of: txt_newsletter_subscription_msg_ch. This will be a message such as:

Quote:
Thank you for subscribing. You will receive an email with a URL in it. Please click on that URL to complete your registration to our newsletter.

Then, create newsletter_subscribe_ch.tpl in the skin1/mail directory and include the following code:

Code:
{* $Id: newsletter_subscribe_ch.tpl,v 1 2003/1/27 06:55:21 lucky Exp $ *} {config_load file="$skin_config"} {$lng.lbl_hello} {$lng.eml_tobe_subscribed} {$http_location}mail/subscribe.php?redirect=customer&email={$email|escape} {include file="mail/signature.tpl"}

Note the creation of eml_tobe_subscribed - this will be something that says

Quote:
This email will be subscribed in the newsletter. Please click on the following link to complete registration.

and finally, modify subscribe_confirmation.tpl in the skin1/main directory to have this code:

Code:
{* $Id: subscribe_confirmation.tpl,v 1.11 2002/10/17 13:54:57 zorg Exp $ *} { include file="location.tpl" last_location=$lng.lbl_newsletter_subscription} {capture name=dialog} {$lng.txt_newsletter_subscription_msg}: {$smarty.get.email} {/capture} { include file="dialog.tpl" title=$lng.txt_thankyou_for_subscribing content=$smarty.capture.dialog extra="width=100%"}

Note that I took out the unsubscribe information. This is not necessary anymore.


Let me know how the installation went. I don't think I left out anything
Reply With Quote
  #2  
Old 03-18-2003, 09:54 AM
 
belen belen is offline
 

Member
  
Join Date: Nov 2002
Posts: 12
 

Default just what the dr. ordered!

thank you so much for this wonderful added customer service bit. we are always very very careful with our opt-in lists, as we are in the adult industry and really respect our user's privacy. this code puts my mind much more at ease that our users will feel protected.

just a small note:

the only thing i found that was off in the code was a missing "/" - i am not sure if it would effect anyone else. but on file skin1/mail/newsletter_subscribe_ch.tpl, i found that this code:

Code:
{$http_location}mail/subscribe.php?redirect=customer&email={$email|escape}

needed to have a "/" before mail:
Code:
{$http_location}/mail/subscribe.php?redirect=customer&email={$email|escape}

again, thank you so much for this code...it helped immensely!

belen
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 04:27 AM.

   

 
X-Cart forums © 2001-2020