Trying to get this mailing list script work: http://www.phptutorial.info/scripts/mailinglist/
I have pasted the whole script from the source page on that site into mailer.php and put it on my local apache server, removing the checkdnsrr line and making the emaillist.txt file.
Problem is when I try and load mailer.php it shows this part of the script printed on the page before the form:
I'm not to good with php but looking at the source in firefox shows all the php up to line 49 being highlighted in pink which leads me to believe there is some mistake in the syntax of the script somewhere? If anyone knows a better script for doing this then I'm all ears but if this works it will do almost exactly what I want it to.
Thanks
I have pasted the whole script from the source page on that site into mailer.php and put it on my local apache server, removing the checkdnsrr line and making the emaillist.txt file.
Problem is when I try and load mailer.php it shows this part of the script printed on the page before the form:
Code:
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.
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. "; } ?> 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(){ ?>
I'm not to good with php but looking at the source in firefox shows all the php up to line 49 being highlighted in pink which leads me to believe there is some mistake in the syntax of the script somewhere? If anyone knows a better script for doing this then I'm all ears but if this works it will do almost exactly what I want it to.
Thanks
Last edited: