+(44) 0845 095 6633
+(00) 1310 512 6058
0845 095 6633

Creating a Newsletter Sign up Form

October 10, 2008 by Andy Russell

Today I will show you how to build on your Web Design skills and create a simple newsletter sign up form. 

After the form has been filled in we will send them to a php page that will process the data and send us an email .

First we have to start with the Form itself.

Here is a basic form asking for Name and Email address.

 

<form id=”form1″ name=”form1″ method=”post” action=”Submit.php”>

<table>

<tr>

<td>Name</td>

<td><input type=”text” name=”name” id=”name” />

</td>

</tr>

  <tr>

<td>Email</td>

<td> <input type=”text” name=”email” id=”email” />

</td>

</tr>

<tr>

<td>&nbsp;</td>

<td> <input type=”submit” name=”button” id=”button” value=”Submit” />

<td>

</tr>

</table>

</form>

 

We are going to post the data through the server to our submit.php page.

This is where we put the script that is used to build the message and email the information over.

 

Create a file called Submit.php, and use the following code.

To tell the server that we are going to be using php we start with the tag “<?php” and close with “?>

 

Right, lets get that data from the form and create the email message.

A few quick basics…

$_POST[‘name’]; //this is the vale of the name field in the form.

$_POST[‘email]; //this is the vale of the email field in the form.

 

Lets set the message up.

$message = ‘You have a received a new Newsletter Sign up customer.\n”;

$message .= ‘The details are Below. \n”;

$message .= ‘Name: ’ ;

$message .= $_POST[‘name’];

$message .= “\n”;

$message .= ‘Email’;

$message .= $_POST[‘email];

 

The full stop before the = sign says $message = itself + $message. This builds the email structure.(the ‘\n’ is a line break)

Lets get this emailed over to us.

mail(‘test@example.com’, ‘My Subject’, $message);

And that is it! 

Here is the code for Submit.php in full..

 

<?php

$message = ‘You have a received a new Newsletter Sign up customer.\n”;

$message .= ‘The details are Below. \n”;

$message .= ‘Name: ’ ;

$message .= $_POST[‘name’];

$message .= “\n”;

$message .= ‘Email’;

$message .= $_POST[‘email];

mail(‘test@example.com’, ‘My Subject’, $message);


?>

  • Digg
  • Google Bookmarks
  • Technorati
  • Facebook
  • del.icio.us
  • MySpace
  • StumbleUpon
  • Sphinn
  • Reddit
  • Mixx
  • Fark
  • NewsVine
  • Live
  • Print
  • email

Related posts:

  1. PPC School: Don’t ask too much from your Lead Conversions
  2. 5 Useful Tips for Creating Great Websites..
  3. Google first to sign deal with Twitter
  4. CSS is Like Poetry – ‘Plan it to Perfection’
  5. No more Site Stats Badge!
  6. Exclude visits from a dynamic IP with Google Analytics


2 Comments

  1. I am looking for a form like on myspace where you can sign up and create an account and all that…

    Comment by Samantha — November 14, 2008 @ 4:48 am

  2. Thanks for the article I will have a go.

    Comment by sam — November 27, 2008 @ 5:21 pm

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

UK Office

Phoenix House
Pyrford Rd, West Byfleet
Surrey, KT14 6RA

Tel: +(44) 0845 095 6633

Email: sales@topclickmedia.co.uk

USA Office

Broadway Plaza
520 Broadway, Suite 350
Santa Monica, California 90401

Tel: +(00) 1 310 512 6058

Email: sales@topclickmedia.com

Resources