Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,152,591 members, 7,816,459 topics. Date: Friday, 03 May 2024 at 11:30 AM |
Nairaland Forum / Science/Technology / Webmasters / Php Gurus Please Help Me Out (799 Views)
Php/mysql Gurus, Please Help Solve This Problem... / Web Gurus,please Help! / Website Designers And Php Gurus Needed Urgently (2) (3) (4)
(1) (Reply)
Php Gurus Please Help Me Out by pretyuk: 5:13pm On Jan 31, 2009 |
Good day gurus in the house. Please am having some difficulty setting my mailing list up. I got this script form net. The script is good it can send and subscribe new users. But the problem I have is that I cant import bulk email since I have up to 300 emails and I cant start inserting them one by one. So I need the assistance of you guys. All i want is to modify the script so that i will be able to import bulk email and at the same time delet bulk emails whenever i want to. Below is tha script I will so much appreciate. Thanks , sub.php <? /* Email list script by phptutorial.info */ // to avoid showning errors (change to 1 to show them). For security error_reporting(0); // if info is posted, show the form and die // the form is in the bottom of the page if (!$_POST){print_form();die();} // when info is posted you will be here ?> <html> <head> <title>Email list</title> </head> <body bgcolor=FFFFFF> <? // GET EMAIL $email=$_POST["email"]; // To avoid problems, only lower case is used $email=strtolower($email); // Check whether email is correct by using a function // function requires the email address and the error message check_email ($email, "Error: email is not valid." // GET VALUE FOR action : subc (subscribe) or unsubc (unsubscribe) $action=$_POST["action"]; // this is the file with the info (emails) // When using the link in the top to download the complete script, a new name for this file // will be generated (p.e.: emaillist-2ax1fd34rfs.txt), so users will be unable to find it $file = "emaillist-kd3KTPLsem.txt"; // lets try to get the content of the file if (file_exists($file)){ // If the file is already in the server, its content is pasted to variable $file_content $file_content=file_get_contents($file); }else{ // If the file does not exists, lets try to create it // In case file can not be created (probably due to problems with directory permissions), // the users is informed (the first user will be the webmaster, who must solve the problem). $cf = fopen($file, "w" or die("Error: file does not exits, and it can not be create.<BR>Please check permissions in the directory or create a file with coresponding name." fputs($cf, "Mailing list subscribers\n" fclose($cf); } // IF REQUEST HAS BEEN TO SUBSCRIBE FROM MAILING LIST, ADD EMAIL TO THE FILE if ($action=="subc"{ // check whether the email is already registered if(strpos($file_content,"<$email>">0){die("Error: your email is already included in this mailing list"} // write the email to the list (append it to the file) $cf = fopen($file, "a" fputs($cf, "\n<$email>" // new email is written to the file in a new line fclose($cf); // notify subscription print "Your email has been added to our mailing list.<br>Thanks for joining us."; } // IF REQUEST HAS BEEN TO UNSUBSCRIBE FROM MAILING LIST, REMOVE EMAIL FROM THE FILE if ($action=="unsubc"{ // if email is not in the list, display error if(strpos($file_content,"<$email>"==0){die("Error: your email is not included in this mailing list"} // remove email from the content of the file $file_content=preg_replace ("/\n<$email>/","",$file_content); // print the new content to the file $cf = fopen($file, "w" fputs($cf, $file_content); fclose($cf); // notify unsubscription print "Your email has been removed from our mailing list. "; } ?> </body> </html> <? // THIS FUNCTION WILL CHECK WHETHER AN EMAIL IS CORRECT OR NOT // FIRST, BASIC ARCHITECTURE IS CHECKED // THEM, EXISTANCE OF THE EMAIL SERVER IS CHECKED // If email is not correct, the error message is shown and page dies function check_email ($email, $message){ // check if email exists if ($email==""{die($message);} // check whether email is correct (basic checking) $test1=strpos($email, "@" //value must be >1 $test2=strpos(substr($email,strpos($email,"@"), "." //value must be >1 $test3=strlen($email); //value must be >6 $test4=substr_count ($email,"@" //value must be 1 if ($test1<2 or $test2<2 or $test3<7 or $test4!=1){die($message);} // check whether email is correct (advance checking) // extracts whatever is after "@" to variable $email_server $email_server=substr($email,strpos($email, "@"+1); // Check DNS records (0 => the server exists; 1=> the server does not exist) if (checkdnsrr($email_server)!=1){die ($message);} } // THIS FUNCTION WILL SHOW THE FORM // MODIFY IT AS REQUIRED function print_form(){ ?> <html> <head> <title>My mailing list</title> </head> <body style="background-color: rgb(255, 255, 255);"> <center> <p> <p> <form action="<? $PHP_SELF; ?>" method="post"> <table> <tr> <td> <div style="text-align: center;"> <big style="font-weight: bold;">Join my mailing list </big><br> </div> <textarea name=email cols=100 rows=20></textarea> <br> <div style="text-align: center;"> <input name="action" value="subc" checked="checked" type="radio">Subscribe <input name="action" value="unsubc" selected="" type="radio">Unsubscribe <br> </div> <div style="text-align: center;"> <input value="Submit" type="submit"> </div> </td> </tr> </table> </form> <!-- you may remove next line, but consider maintaining it --> <font size="2">Script provided by <a href="http://www.phptutorial.info/">PhpTutorial.info</a>. </font></center> </body> </html> <? } // the function finishes here ?> send.php <? error_reporting(0); //############################################################# //################# CONFIGURATION ########################## // choose a password $my_password=""; // the email from which emails are send // mydomain.com must be your real domain, otherways, // the server will not send any emails $from_email="Ukamaka Eze <prety_uk@yahoo.com>"; // Your replay to email (whatever you want). $replayto="prety_uk@yahoo.com"; // A message to be attached to the bottom of the message // We recommend to add a link to subscription page $message_at_bottom=" ------------------------------------------------------------ P.D.: To remove from this list go to, http://mydomain.com/mlist/import.php "; // The file where emails are stored $emails_file="emaillist-kd3KTPLsem.txt"; //############### END CONFIGURATION ######################## //############################################################# // IF INFO IS NOT POSTED, PRINT THE FORM AND DIE if (!$_POST["mensaje"]){ print_form(); die(); } // IF INFO IS POSTED YOU WILL BE HERE // Check whether the password is correct // (only webmaster is supposed to know the password, which has been specified above) if ($_POST["p"]!=$my_password){die("Incorrect password"} // Get the subject of message $subject =$_POST["subject"]; // Get the body of message $message=$_POST["mensaje"]; // Add to body of message the bottom $message.=$message_at_bottom; // Read the file with emails to variable $emails_file $emails_file=file_get_contents($emails_file); // Extract list of emails to array $emails_array preg_match_all("/<.{0,100}?>/",$emails_file,$emails_array); // Start output print "<b>Sending messages, </b>"; // Send email to each email foreach ($emails_array[0] as $email){ // remove "<" and ">" from each email $email=substr($email,1,strlen($email)-2); // Next line is the one sending the email: the key command of this script mail($email, $subject, $message,"From: $from_email\nReply-To: $replayto\nContent-Type: text/plain" // Each time an email is send, output it print "<br>$email\n"; // After sending each email, send previous line (the email) to the browser flush(); } ?> </body> </html> <?php // THIS FUNCTION WILL SHOW THE FORM // MODIFY IT AS REQUIRED function print_form(){ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> <title>My email list</title> </head> <body style="background-color: rgb(255, 255, 255);"> <center> <a href="import.php" target="_blank"><h2>IMPORT EMAILS</h2></a> <table style="font-family: times new roman;" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td style="vertical-align: top;"> <form method=POST action="<? $PHP_SELF; ?>".php> Subject <br><input type=text name=subject size=40> <br>Message <br><textarea name=mensaje cols=100 rows=20></textarea> <br>Password <input type=password name=p size=10> <br><input type=submit value=Send> </form> </td> </tr> </tbody> </table> </center> </body> </html> <? } ?> |
(1) (Reply)
I Want To Edit And Upload A Website / Please Webmaster Review This Site Please Www.mcpatolive.com / Etranzact
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 39 |