Your Ad Here

 Navigation
Home
Source code
Tutorials
RSS feeds
Articles
Wordpress plugins
Blog
Books
Software
Downloads
Hosting
manuals
Script directory
Training
Our Links




 Sponsors
 Links
wwwstores
low cost magazines
software directory
 Downloads
 Misc
Webmaster Resources
Only PHP
ScriptSearch.com
Scripts.com - Get the best scripts NOW!
AndreaPHP Programming

Valid XHTML 1.0 Transitional


Valid CSS!


Mailing List example


Mailing List example

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>

And here is what was displayed when we accessed this page , just as we expected.

Now 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.

Back to section 2 , Forward to Section 4




Books
 Sponsors
 Random Code
Page last accessed(date/time)
PHP captcha example(image)
list all databases(database)
 Random Article
  Network
Programming resources
Tutorials directory
Clickbank mall
sell software
Free auctions, low cost stores
UK products
US products
Gambling directory
Sexy free wallpapers
Hosting resources
ASP site
DVD site
Domain names
Dating site
Software directory
Maxi directory
bigarticle : free articles




beginners PHP Copyright © 2004 onwards by beginnersPHP.