Click to See Complete Forum and Search --> : poll and mailing list


chris9902
09-19-2003, 04:57 PM
I want to add some extras to a site but i don't want those crappy ones like bravenet.

i want to add a simple web poll. press a radio button, submit and it change from the options to the results.

and i don't no if this is possible but i want to make a mailing list but i want it so when you type your email in a text box you choose text or HTML and if you choose HTML that email address is saved to one .txt file but if you choose text it goes to another .txt file.

so i can then just use the CC option and mail it out.

and i want to be able to change the look of it using CSS.

if anyone can help... thanks alot:)

pyro
09-19-2003, 05:11 PM
Yep, all this can be done with PHP. If you don't have any scripts yet, take a look around http://php.resourceindex.com/ and http://www.hotscripts.com/ and see if they have anything that matches what you are looking for.

chris9902
09-19-2003, 05:20 PM
ok, i got one :: http://www.onlinetools.org/tools/easyletter.php ::


<?php
/*
EasyLetter 1.2
This script is part of Onlinetools
http://www.onlinetools.org/tools/easyletter.php
*/
$vars=explode(",","pw,send,subject,message,email,action");
foreach($vars as $v){
if ($HTTP_GET_VARS[$v]!=""){$$v=$HTTP_GET_VARS[$v];}
if ($HTTP_POST_VARS[$v]!=""){$$v=$HTTP_POST_VARS[$v];}
}
# Set the password for the eMail List editor!
$pass="secret";

# Where is your newsletter located? (For deletion link)
$newsletterlocation="http://www.foo.com/easyletter.php";

# Name of the datafile
$filelocation="subscribers.txt";

# Title of the newsletter, will be displayed in the FROM field of the mailclient
$lettername="newsletter@bar.com";

# Your email, will be the reply-to mail,
$youremail="foo@bar.com";

# pattern for filtering out own emails
$pattern = "bar.com";

$welcomemessage = "";

# Sorrymessage for failed subscription, will be followed by the email!
$sorrysignmessage = "<div class=\"warning\">Sorry, but there is already an entry for $email</div>";

# Sorrymessage for blank email
$sorryblankmailmessage = "<div class=\"warning\">Sorry, but with a blank mail I get lost in cyberspace</div>";

# Sorrymessage for invalid emails
$sorryoddmailmessage = "<div class=\"warning\">Sorry, but \"$email\" that does not look like an email to me</div>";

# Sorrymessage if someone entered your own mail
$sorryownmailmessage = "<div class=\"warning\">Sorry, but I don't really want to get my own newsletter!</div>";

# Subscribemessage, will be shown when someone subscribes.
$subscribemessage = "<div class=\"thanks\">Thank you for subscribing to the newsletter, a confirmation email is on its way!</div>";

# Subscribemail, will be sent when someone subscribes.
$subscribemail = "Thank you for subscribing to the newsletter.";

# Unsubscribemessage for deletion, will be followed by the email!
$unsubscribemessage = "<div class=\"thanks\">We deleted the email</div>";

# Unsubscribemessage for failed deletion, will be followed by the email!
$failedunsubscriptionmessage = "<div class=\"warning\">Sorry, you cannot unsubscribe as we didn't find an entry for $email</div>";

if (!file_exists($filelocation)) {
$newfile = fopen($filelocation,"w+");
fclose($newfile);
}
$newfile = fopen($filelocation,"r");
$content = fread($newfile, filesize($filelocation));
fclose($newfile);
$content=stripslashes($content);
$out="";
$lines = explode("%",$content);
foreach($lines as $l){
if ($l != $email){$out .= "%".$l;}
else{$found=1;}
}
if ($action=="sign"){
if ($found==1 or $email=="" or !checkmail($email) or preg_match("/".$pattern."/",$email)){
if ($email==""){echo $sorryblankmailmessage;}
else if ($found==1){echo $sorrysignmessage;}
else if (!checkmail($email)){echo $sorryoddmailmessage;}
else if (preg_match("/".$pattern."/",$email)){echo $sorryownmailmessage;}
$disp="yes";
}
else {
$disp="no";
$newfile = fopen($filelocation,"a+");
$add = "%".$email;
fwrite($newfile, $add);
fclose($newfile);
echo $subscribemessage;
mail ($youremail,"New newsletter subscriber.",$email."\nDelete? $newsletterlocation?action=delete&email=".$email,"From: Newsletter\nReply-To: $email\n");
$submailheaders = "From: $lettername subscription form\n";
$submailheaders .= "Reply-To: $youremail\n";
mail ($email,$lettername." subscription",$subscribemail,$submailheaders);
}
}
if ($action=="delete"){
$disp="no";
if ($found == 1){
$newfile = fopen($filelocation,"w+");
fwrite($newfile, $out);
fclose($newfile);
echo $unsubscribemessage;
$disp="no";
}
if ($found != 1){
echo $failedunsubscriptionmessage;
$disp="YES";
}
}
if ($pw == $pass){
if ($send != "yes" && $send != "test"){
print'<form method="post"><input type="hidden" name=pw value='.$pass.' /><input type="hidden" name="send" value="yes">
<br /><b>Newsletter editor:</b><br /><br />
Subject:<br />
<input type="text" class="input" name="subject" size="20"><br />
Message:<br />
<textarea cols="50" rows="10" class="input" wrap="virtual" name="message"></textarea> 
<input type="submit" value="send" />
</form>';
}
$mailheaders = "From: $lettername\n";
$mailheaders .= "Reply-To:$youremail\n";

# If you want to send HTML mail, uncomment this line!
// $mailheaders .= "Content-Type: text/html; charset=iso-8859-1\n";
if ($send == "yes"){
$message="".stripslashes($message);
$subject=stripslashes($subject);
$lines = explode("%",$content);
foreach ($lines as $l){mail ($l,$subject,$message,$mailheaders);}
print "<b>The following email has been sent!</b>";
print "<pre>$mailheaders\n$subject\n$message</pre>";
}
}
if ($pw != $pass && $disp != "no"){
print $welcomemessage;
print'
<form method="post">
Your email: <input type="text" name="email" class="inputsmall" value="" size="20" /> 
<input type="radio" name="action" value="sign" checked="checked" />subscribe
<input type="radio" name="action" value="delete" />unsubscribe 
<input type="submit" value=" Send! " class="button" />
</form>
';
}
print "<!-- Easyletter Newsletterscript by Chris Heilmann, get yours @ http://www.onlinetools.org/easyletter/ -->";

function checkmail($string){
return preg_match("/^[^\s()<>@,;:\"\/\[\]?=]+@\w[\w-]*(\.\w[\w-]*)*\.[a-z]{2,}$/i",$string);
}
?>


is that what i am looking for, it looks ok to me

pyro
09-19-2003, 05:28 PM
Originally posted by chris9902
is that what i am looking for, it looks ok to melol... :D I think that is a question you have to answer.

chris9902
09-20-2003, 08:26 AM
ah come on i suck at PHP, i don't know do i....:D

spykemitchell
09-21-2003, 09:50 AM
This will do what you want except you haven't got the choice whether they want HTML or Pure text...

You could allways duplicate the script placing it in seprate directories and then use a hyperlink for choosing,

<a href="plain/index.php>Plain text email</a>

<a href="html/index.php">html email</a>

Spyke.