View Full Version : Wanting to start a mailing list

08-16-2007, 10:51 AM
Hey everyone :) ,

I am really interested in putting a mailing list on my website. I have only just discovered php and mysql and I found a program called php list on my cPanel X control panel on my website.

I would like to put a text box on my navigation bar that has inside it "enter your e-mail" (when they click this disappears) and a button on the right of that which says "join" (I will have a jpg underneath this text box saying "Mailing List").

When someone clicks on "join" I would like them to get sent to a page with the e-mail address field filled out in the right table with what the address they entered in the navigation pane, along with a name field they can fill out and a Submit button.

I have seen these on many websites so I assume it is not that hard to do, but I am pretty lost as to how everything is connected (the database (mysql?) and the php list program).

I assume when they click submit it will send their details to a mysql database / send them a confirmation e-mail.

I was wondering what code I will need to make this system work, as I have been reading and googling and I am quite lost as to the mechanics of how it all works :( :( :confused:

Any help is appreciated!

- Sepp.

08-16-2007, 11:34 AM

you will need to use javascript to make the text in the box disapear when you click it, and PHP for loading the email addresses into the DB.

javascript: (use this in the textbox)

onclick="if( this.value =='Enter keyword'){this.value=' '}"

Full Example:


if(isset($_POST['emailAddress']) and $_POST['emailAddress'] != 'Enter Email Address')

$hostname_conn_email = "server Address";
$database_conn_email = "database";
$username_conn_email = "username";
$password_conn_email = "password";

$conn_email = mysql_pconnect($hostname_conn_email, $username_conn_email, $password_conn_email) or trigger_error(mysql_error(),E_USER_ERROR);

mysql_select_db($database_comm_email, $conn_email);

$insertSQL = "INSERT INTO databaseName (fieldname) VALUES ('".addslashes($_POST['emailAddress'])."')";

$result1 = mysql_query($insertSQL, $conn_email) or die(mysql_error());


<form id="form1" name="form1" method="post" action="<?=$_SERVER['PHP_SELF']?>">
<input name="emailAddress" type="text" id="emailAddress" value="Enter Email Address" onclick="if( this.value =='Enter Email Address'){this.value=' '}" />
<input type="submit" name="Submit" value="Join!" />

I havn't checked this but i am sure that i will work but may need tweeking a bit.