How can I put a form on my homepage saying "If you would like to be notified when we add ringtones to our site, please enter your e-mail in the box and hit Submit. We will only notify you when 5 or more new ringtones are added, and we will never sell or give out your e-mail address." Then I want to be able to go to an admin only page like http://www.ringercentral.com/emailsend.php and I want to be able to type in a Subject and Message, then mass e-mail the users when I put 5 new ringtones onto the website. And how could I make it so only I could access /emailsend.php
If you are looking to have someone build the PHP for you, you might consider posting it in teh Buy/Sell/Trade section of the forum. It wouldn't be too tough to build what you are asking for. A simple capture form that deposits information in a MySQL database would be all you would need to get the data. I could build it for you for $100.
My friend would do it for free later today, I was just wondering how hard it would be. Thanks anyway.
First you need to create a mysql database and table where you can store emails. Hope you know how to create one... if so create one then post here your tables structure I may give you a simple code for it.
Thanks PinoyIto, I think I did it right. I had a twan_mainh table which took care of displaying my artist and songs through AJAX, so I put in a third table called emails So twan_mainh_emails Do you need more info?
People are going to think i'm a schill for hotscripts (I only wish I owned that site) but: http://www.hotscripts.com/PHP/Scripts_and_Programs/Mailing_List_Managers/index.html Getting e-mail addresses into a db is easy. Mass e-mailing that list is not difficult but definately a lot more work if you want to do it securely and right. Add in reasonable requirements like removing bounced/invalid emails and allowing users to unsubscribe themself and you're getting into fairly complicated territory where you'd be far better off using one of the hundreds of available scripts.
Okey let's try to make the simpliest code we can do, please take note I never tried this one I directly type it here you may find some bugs but minimal I guess. Let's say in your twan_mainh_emails table you have field name email and firstname Here is the form, insert it in your main page where you want the form will show. <form method = "post" action = "savemail.php"> you would like to be notified when we add ringtones to our site, please enter your e-mail in the box and hit Submit. We will only notify you when 5 or more new ringtones are added, and we will never sell or give out your e-mail address. <p> First Name <input type="text" name = "firstname" size = "20"><br> Email Address <input type = "text" name ="email" size = "20"><br> <input type="submit" value ="Submit" name ="submit"> </form> Code (markup): conn.php connect to db file $dbname=""; //your database name $dbuser="";//your database username $dbpass="";//Your database password $server = "localhost"; // change localhost if you use diffirent server name $db = mysql_connect("$server","$dbuser","$dbpass"); mysql_select_db("$dbname",$db) or die("Can't open database"); Code (markup): Here is the code for savemail.php <?php include "conn.php"; if($_POST[firstname]=="" || $_POST[email]==""){ echo "Both fields are required. Please hit your back button to correct the problem"; exit(); } //Check if valid email format if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$_POST[email])){ echo "invalid email format"; exit; } //Next check if the email entered is already exist $sql = "Select * from emails where email = '$_POST[email]'"; $rec = mysql_query($sql) or die(mysql_error()); if(mysql_numrows($rec)>0){ //exist exit echo "This email is already exist in our database"; exit; } else { // Save email to emails table mysql_query("INSERT INTO email(`firstname`,`email`) VALUES('$_POST[firstname]','$_POST[email]')"); echo "<h2>Thank you for subscribing</h2> Your email have been added to our database. <a href='index.php'>Back</a>"; } ?> Code (markup): So that's it you have your script that will save email... now create the form where you can enter your message... emailform.html <html> <head> <title> Send Email</title> </head> <body><table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1" height="216"> <tr> <td width="20%" height="19"> </td> <td width="60%" height="19"> <h1>Email dispatch for all subscriber!</h1> </td> <td width="20%" height="19"> </td> </tr> <tr> <td width="20%" height="19"> </td> <td width="60%" height="19"> <form method="POST" action="sendmail.php"> <b>Subject :</b> <input type="text" name="subject" size="61"> <p>Your Message : <p> <textarea rows="29" name="message" cols="64"></textarea> </p> <p align="center"> <input type="submit" value="Send Message" name="B1"></p> </form> </td> <td width="20%" height="19"> </td> </tr></table></body></html> Code (markup): Then the script to send buld email... this work only if your server support the php mail() function sendmail.php <?php include ("conn.php"); $sql="SELECT * FROM emails ORDER BY email"; $rs = mysql_query($sql,$db) or die(mysql_error()); $fld = mysql_fetch_array($rs); $ctr=0; $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\n"; $headers .= "From: \"$domain\" <webmaster@$domain.com>\n"; $headers .= "Reply-To: \"$domain\" <webmaster@$domain.com>\n"; $headers .= "X-Mailer: PHP's mail() Function\n"; do { if($fld[email] != "" || !empty($fld[email])){ $ctr++; echo "Email Sends to $fld[email] <br> $ctr"; mail("$fld[email]","$_POST[subject]","$_POST[message]","$headers"); } } while ($fld=mysql_fetch_array($rs)); echo "<h1> Message send to $ctr subscribers</h1>"; ?> Code (markup):