Your Ad Here

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




 Sponsors
 Links
dvd information
finance products
low cost magazines
 Downloads
dzphp editor
EasyPHP
mysql_phpgenerator
php-studio-trial
phpdesigner_7_2_5
phpMyAdmin-3.4.3.2
/phptriad2-2-1
phpxedit_321
rapidphp 2011
WampServer2.1d-x64
WampServer2.1e-x32
xampp-win32-1.7.4-VC6-installer
xampplite-win32-1.7.3
 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
create a date(date and time)
an example of a class in php(beginner)
Check number of characters(string)
 Random Article
  Network
Programming resources
Tutorials directory
Hosting resources
ASP site
Domain names
Progged
Maxi directory
bigarticle : free articles
A Code
Code N Tutorials
Get PHP
Programmers help




beginners PHP Copyright © 2004 onwards by beginnersPHP.