Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions > Programming Tips and FAQ » Use AJAX and PHP to Build your Mailing List
Closed Thread
Old 02-16-2007, 10:57 PM   #1 (permalink)
office politics's Avatar
 
It's all just 1s and 0s

Join Date: Jan 2004

Location: in the lab

Posts: 4,410

office politics will become famous soon enough

Default Use AJAX and PHP to Build your Mailing List

Use AJAX and PHP to Build your Mailing List
By Aarron Walter
November 1st 2006

Reader Rating: 9

An elegantly designed site filled with engaging content is worth very little without an interested audience. An opt-in mailing list is one of the most effective methods of making contact with your audience and driving repeat traffic to your site. If visitors enjoy and trust your site, they're likely to trust you with their email addresses -- after all, they'll want to be informed of new products, articles, or other relevant information. This is a great way to build relationships with your site's users, and encourage them to come back to your site again and again.

In this article, we'll learn to use AJAX to accept subscriptions to your mailing list without having to refresh the page; with this approach, your signup process will be quick and painless. Our AJAX sign up form will also be able to accept subscriptions from visitors who don't use modern, AJAX-capable browsers.

This article assumes that your mailing list is stored in a MySQL database, but as long as you have the necessary code to add addresses to your own mailing list, it should be easy for you to adapt the code presented in this article to your own signup process.

Before we get started, download the code, and take a look at what we'll cover in this tutorial.

The Big Picture
Our mailing list signup system has three key components:


An HTML form inside a PHP page receives the visitor's email address.

JavaScript will listen for the form submission, which will trigger the AJAX call to the server with the email address.

A simple PHP page on the server will receive the address. It will check the email address for errors, then store the address in a MySQL database. A success or error message will be sent back to the HTML page for user feedback.

We'll also ensure that this signup functionality is accessible to all, by writing a PHP-based sign up for users who don't have JavaScript enabled in their browsers.
office politics is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On