Forums
This topic is locked
Contact Form & Mailing List
Posted 06 Aug 2003 14:09:45
1
has voted
06 Aug 2003 14:09:45 Darren Nicholls posted:
I've created a simple contact form for testing purposes, it has name, email, message & 'add to mailing list option'The form is processes by a form called form.php, the part that proccesses the form is ok, however I wanted to add a 'add to mailing list option' basically if the user presses the check button they are added to the mailing list., i've taken the part of the script that deals with the mailing list from another script & so the finished form is a little bit ruff;
<?
//If statement
if ($_POST['action'] == "subscribe" {
//They selected subscribe Connect to the database
//Connect to the database
mysql_connect("server", "username","password"
//Select the database
mysql_select_db("database"
//Connected to the DB, and they selected subscribe so add them to it!
//The email from the form they submitted
$email = $_POST['email'];
//The insert query to add them to our database
$sql = "
INSERT INTO subscribers SET
email = '$email'
";
//run the query
$query = mysql_query($sql);
//User added to database
//Declare the variables for sending the email
/* $recipient =$_POST['address']; */
$recipient = " ";
$subject =$_POST['subject'];
//Contents of Form
$name=$_POST['name'];
$email=$_POST['email'];
$comments=$_POST['comments'];
//mail() function sends the mail
mail ($recipient, $subject, $message, $email);
//Redirect page
header("Location: mysite.co.uk/redirect.php");
}
?>
There are a few otions that I need to add but am a bit stuck, firstly if the user has already been added to the mailing list how can I let them know that there already on it?
Would it be possible on the redirect page to have what they typed on the form, &if they've been added to the mailing list/already on the mailing list?
I would also like to auto generate an email to inform them that they have subscribed.
Are there any extensions available to do what I'm trying to do? as I don't want to reinvent the wheel!! Thanx DJN