I got a 'newsletter signup form' on my webpage in a layer with 2 fields 'name' and 'email'
I am using the POST method and opening up a 'addemails.php' page up in a new window that should be inserting records and displaying a 'thank you' message (I will be doing validation checking as soon as i know the Insert command works)
The database has one table called 'newsletter' with 3 fields: 'index' (auto-increment); 'name' 'email (both varchar 50)
Here is the 'addemails.php' code:
Any help is much appreciated... I'm rather new to PHP and this is rather frustrating since I basically copy/pasted working code in and changed the information for my db...
Jason
I am using the POST method and opening up a 'addemails.php' page up in a new window that should be inserting records and displaying a 'thank you' message (I will be doing validation checking as soon as i know the Insert command works)
The database has one table called 'newsletter' with 3 fields: 'index' (auto-increment); 'name' 'email (both varchar 50)
Here is the 'addemails.php' code:
Code:
<?
//initialize PHP
if($_POST['submit']) //If submit is hit
{
//then connect as user
//change user and password to your mySQL name and password
mysql_connect("localhost","web","eso1com");
//select which database you want to edit
mysql_select_db("oakhills");
//convert all the posts to variables:
$name = $_POST['name'];
$email = $_POST['email'];
$sql = "INSERT INTO newsletter (index,name,email) VALUES ('', '$name', '$email')"
//Insert the values into the correct database with the right fields
$result=MYSQL_QUERY("INSERT INTO newsletter (index,name,email) VALUES ('', '$name', '$email')");
//confirm
?>
Any help is much appreciated... I'm rather new to PHP and this is rather frustrating since I basically copy/pasted working code in and changed the information for my db...
Jason