Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-30-2003, 03:30 PM
ice9 ice9 is offline
 
Join Date: Jun 2003
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default php to append emails to text file

I'm looking for a simple modification to register.php that will append the email addresses of newly registered users to a text file for addition to my mailing list (lyris). I looked through the hack archives, and found some other more robust mailing list features, but I'm looking for something a lot simpler. I'm coming from a perl background, and am relatively new to php.

I just need a plain checkbox on my registration form "check here to receive our newsletters, etc.", that will append the email to a text file. Then, I'll just cron something nightly to add the email addresses to my lyris list. I don't need to check it against a list to see if they are already subscribed.
Reply With Quote
  #2  
Old 07-05-2003, 11:29 AM
Gavin B. Gavin B. is offline
 
Join Date: Jul 2003
Location: Australia
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

in register somewhere (I'd suggest just below the insert database query around line 459 in register.php

PHP Code:
$fp fopen("emails.txt""a");
    
fwrite($fp"$email\r\n");
fclose($fp); 
That directory will have to be chmod'ed for writing (777) however. You may wish to stick the text file somewhere below root level
Reply With Quote
  #3  
Old 07-05-2003, 11:35 AM
noppid noppid is offline
 
Join Date: Mar 2003
Location: Florida
Posts: 1,875
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP can access anywhere in the file system if I'm not mistaken. So put your mailing list ABOVE the web root folder in a writable folder. It's safe from hackers and you don't have to have a public writable folder.
Reply With Quote
  #4  
Old 07-05-2003, 11:40 AM
Gavin B. Gavin B. is offline
 
Join Date: Jul 2003
Location: Australia
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think that's what I meant The path would be something like:
/home/username/emails.txt
Reply With Quote
  #5  
Old 07-08-2003, 06:23 PM
ice9 ice9 is offline
 
Join Date: Jun 2003
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks -- that was easy . Is there a simple way to only append the email to the text file if a checkbox was checked? This way, I can keep my list opt-in only.
Reply With Quote
  #6  
Old 07-08-2003, 09:39 PM
noppid noppid is offline
 
Join Date: Mar 2003
Location: Florida
Posts: 1,875
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try this.

in the register templates add...
<tr>
<td bgcolor="{firstaltcolor}"><normalfont><b>Join our mailing list?</b></normalfont><br>
<smallfont>Selecting yes will add you to our mailing list.</smallfont></td>
<td bgcolor="{firstaltcolor}"><normalfont>
<input type="radio" name="wantsmail" value="yes"> yes
<input type="radio" name="wantsmail" value="no" checked> no
</normalfont></td>
</tr>

in register.php at around line 350 add

$maillist=iif($wantsmail=="yes",1,0);

then wrap the append code in an if()...

if($maillist) {
$fp = fopen("emails.txt", "a");
fwrite($fp, "$email\r\n");
fclose($fp);
}

This is not tested.
Reply With Quote
  #7  
Old 07-14-2003, 03:42 PM
ice9 ice9 is offline
 
Join Date: Jun 2003
Posts: 34
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks noppid -- worked perfectly .
Reply With Quote
Reply


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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:57 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07192 seconds
  • Memory Usage 2,215KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete