-6

I'm trying to make a simple form like this http://birdboxx.com/, where the user can enter their email address to be notified when our site has launched.

I've looked at the HTML their using and it all looks pretty simple, I'm just not sure on how to code the PHP part. Could someone maybe help me out?

Thanks in advance.

  • 5
    ehh, you have to at least attempt this yourself, and come back with a specific question. i mean the functionality you are asking for requires setting up a database, and database tables, and creating PHP functionality to store email addresses, then retrieve a list, or send out a mass mail depending on what you are looking for. – dqhendricks Jan 06 '11 at 21:27
  • Sorry, I did mean just some help in pointing me the right direction. – Raphael Essoo-Snowdon Jan 07 '11 at 03:40
  • You need to capture the email save it somewhere. When the site lauches you need to send a mass email. It sounds like a rudimentary email newsletter subscription box with a one time mailing. – Byron Whitlock Jan 07 '11 at 21:49

2 Answers2

1

The form in the given example (the relevant parts):

<form name="form-email-submit" id="form-email-submit" action="add_email.php" method="POST">
   <input type="text" id="input-email" name="input-email" value="Enter your email here"/>
   <input type="submit" title="Notify Me" value="Notify Me">
</form>

In your PHP script:

//In the add_email.php
$notificationEmail = $_POST['input-email']; // from the name="input-email" in the form

So now you have the email submitted, you can do whatever you want with it. You can write it to a file, or save it to a database, or whatever.

Aston
  • 3,654
  • 1
  • 21
  • 18
1

Basic solution for the email saving part.

The HTML:

<form method="post" action="">
<input type="email" name="email" placeholder="Enter your email here" /> <input type="submit" name="send" value="Notify me" /> 
</form>

The PHP with MySQL for saving:

$dbhost = "your host";
$dbuser = "your username";
$dbpass = "your password";
$dbname = "database name";  
$c = @mysql_pconnect($dbhost,$dbuser,$dbpass) or die();
@mysql_select_db($dbname,$c) or die();

//It isn't secure in this state: validation needed as it is an email?
if(isset($_POST['send'])){
    $email = mysql_real_escape_string($_POST['email']);
    mysql_query('INSERT INTO email (id,email) VALUES (NULL,'.$email.');');
}

For sending emails I recommend phpmailer or any other solution: http://phpmailer.worxware.com/

Ákos Nikházy
  • 1,276
  • 17
  • 33