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
programmershelp
software directory
wwwstores
 Downloads
 Misc
Webmaster Resources
Only PHP
ScriptSearch.com
Scripts.com - Get the best scripts NOW!
AndreaPHP Programming

Valid XHTML 1.0 Transitional


Valid CSS!


Simple Mailing List example


Simple Mailing List example

In this section we will create a form for the user to fill in and also we will create a script to log the results into our email database . So without any further ado lets create our form.

Here is the code .

<form action = "joinnewsletter.php" method = "post">
<table>
<tr><td>
Name : </td>
<td><input type = "text" name = "name">
</td></tr>
<tr><td>
Email :
</td>
<td><input type = "text" name = "email">
</td></tr>
<tr><td>
<input type = "submit" value = "join"></td>
<td><input type = "reset" value = "clear"></td></tr>
</table>
</form>

Which will produce our form . Now we will store the user submitted details into our database . Call this joinnewsletter.php and enterthe following code .

<?php
//make a connection
$connection = mysql_connect("localhost" , "iainhendry" , "iain06")
or die("cannot make connection");
//select our database email
$db = mysql_select_db("email" , $connection)
or die("cannot find database");
//insert the values of our form into our database
$sql_query = "INSERT INTO email VALUES (\"$name\",\"$email\")";
$results = mysql_query($sql_query);
//display a thank you message and a link
echo ("Thank you for subscribing to our newsletter<br>");
echo ("<a href = 'index.htm'>Back to index page</a>");
?>

Now enter some data in the form and press submit (preferrably valid data) . Now we will check our table using MySQL , at the command prompt enter this .

SELECT * FROM email;

Here was what was displayed when I entered a coupl of my ffa submission emails addresses.

As you can see the email addresses and name has been added.

In our next part we will be displaying the available email addresses and also showing how to send messages to all addresses in the database.

Back to Part 1 , Forward to Part 3




Books
 Sponsors
 Random Code
create a date(date and time)
PHPInfo to a log file(file system)
convert binary to decimal(math)
 Random Article
  Network
Programming resources
Tutorials directory
Hosting resources
ASP site
Domain names
Progged
Maxi directory
bigarticle : free articles
A Code
Code N Tutorials




beginners PHP Copyright © 2004 onwards by beginnersPHP.