Free Webmaster Resources .info
PHP Introduction and Tutorials Javascript  Introduction and Tutorials HTML  Introduction and Tutorials ASP  Introduction and Tutorials Free Internet Access Guide and Directory Webspace  Directory Webhosting  Directory Adult Webhosting  Directory PHP Hosting  Directory ASP Hosting  Directory
à Navigation
» Home
» Php Introduction
» Php Tutorials
» Submit Scripts
 
Subscribe for free!

Join our mailing list today and recieve free updates monthly with web hosting specials!
 
 

 

 

Free Webmaster Resources .info | Free PHP Tutorials


Mailing List in PHP

This is our 3rd part of our mailing list example, we will now display all subscribers to our newsletter on a page , this would be used for admin purposes mainly and is always useful to have.

Here is the code for the page which we called shownewsletter.php to display the data

<html>
<head></head>
<body>
<?php
//shownewsletter.php
//shows all current subscribers to our newsletter
//make a connection
$connection = mysql_connect("localhost" , "iainhendry" ,"iain06")
or die("cannot make connection");
//select or database
$db = mysql_select_db("email", $connection)
or die("cannot find database");
//create our sql query
$sql_query = "SELECT * FROM email";
//execute query
$result = mysql_query("$sql_query");
//now display the results on the page
echo ("<table border ='1' width = '60'>");
//loop through our email table
while ($rows = mysql_fetch_row($result))
{
//$rows[0] is our name and $rows[1] is our email
echo ("<tr><td>$rows[0]</td><td>$rows[1]</td></tr>");
}
?>
</body>
</html>


N ow our second part is removing a subscriber , this is usually place at the bottom of the email as a link.The subscriber will thewn go to a page with a form on it and enter his name and email address and remove himself/herself from the list. Firstly lets build a form .

<form action = "removemenow.php" method = "post">
<table>
<tr>
<td> Name : </td>
<td>
<input type = "text" name = "name2">
</td>
</tr>
<tr>
<td> Email : </td>
<td>
<input type = "text" name = "email2">
</td>
</tr>
<tr>
<td>
<input type = "submit" value = "remove" name="submit">
</td>
<td>
<input type = "reset" value = "clear" name="reset">
</td>
</tr>
</table>
</form>

Similar to before so we will not dwell on this too much , now for the removemenow.php which does the work of removing the selected e-mail address.

<?php
//removemenow.php
//this script removes an user from the list
$connection = mysql_connect("localhost","iainhendry","iain06");
$db = mysql_select_db("email" , $connection);
$sql_query = "DELETE FROM email WHERE email = '$email2'";
$result = mysql_query("$sql_query");
echo ("You have unsubscribed");
?>

In our next section we will build a form for webmasters and then send the newletter to all subscribers in our list.

<Top | Back


Recommended Webhosting Company
Find free web hosting
Looking for free web hosting? Review and compare FindStuff's comprehensive resources. Search now!

 

 
Related Websites
 


Free Email
Your source to free email.

Free Casino Downloads
Contains useful free casino downloads.

Free Software Downloads
A complete collection of free software downloads.

Free
Download free stuff from psike.com your free stuff resource.

Free Teen Online Dating
Meet other singles for free online dating.

Coolfreeweb.com
The Free category at coolfreeweb.com

My Directory Listing
A massive directory listing of websites

Website Collation Project
The website collation project contains a huge directory of websites.


 
Top Webhosts
 
 1. Find free web hosting
 2. Free Web Hosting
 3. Web Hosting
 4. Free Web Hosting
 5. Web And Hosting
 
-
- Give us feedback
 
Last updated
Oct 11, 2008
Free Webmaster Resources .info | A resource must for every web master
Untitled Document - Web Hosting
- PHP Hosting
- Free Internet Access