vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   php to append emails to text file (https://vborg.vbsupport.ru/showthread.php?t=54891)

ice9 06-30-2003 03:30 PM

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.

Gavin B. 07-05-2003 11:29 AM

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

noppid 07-05-2003 11:35 AM

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.

Gavin B. 07-05-2003 11:40 AM

I think that's what I meant ;) The path would be something like:
/home/username/emails.txt

ice9 07-08-2003 06:23 PM

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.

noppid 07-08-2003 09:39 PM

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.

ice9 07-14-2003 03:42 PM

Thanks noppid -- worked perfectly :).


All times are GMT. The time now is 06:41 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.04427 seconds
  • Memory Usage 1,722KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete