|
mailing list php problem
Hi-
I am new with php and mysql and having a good bit of trouble setting up an email subscriber
form on a website I maintain. The site is hosted with godaddy and, after 2 days on the phone
with them I've come to the conclusion that while I'm not the brightest bulb on the tree, they
really don't want to be of much help.
I purchased a "website building for dummies" type book which contained the following code, meant by the author
as a "works across the board" kind of document. Unfortunately, it doesn't work in this case.
When I input information from the form I created it seems fine, but then when I check the database,
a new record has been created but the fields are empty.The database is simple in that only
three fields are required, the "ID", the subscriber's name, and the subscriber's email address.
Can anyone tell he either a) what is wrong with the php document below or b) does anyone
have a sample document that they know works with godaddy hosting that I might use?
Thanks in advance. here's the code that doesn't work:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?php
$Name=$_POST['Name'];
$EMail=$_POST['EMail'];
$connection=mysql_connect ("databaseaddress",
"myusername", "mypassword") or die ('I cannot
connect to the database.');
mysql_select_db ("mydatabase",$connection) or die(
"Unable to select database");
$query = "INSERT INTO `mytable` (`ID`, `Name`,
`EMail`) VALUES ('', '$Name', '$EMail')";
mysql_query($query);
mysql_close();
?>
</body>
</html>
One last thing...when building the database I used the following field settings:
ID:
type-integer, legnth-4, collation-empty, attributes-unsigned, null-no, default-empty, extra-auto_increment, primary key
Name:
type-varchar, length-40, collation-UTF8_unicode_ci, attributes-empty, null-no, default-empty, extra-empty
EMail:
type-varchar, length-40, collation-UTF8_unicode_ci, attributes-empty, null-no, default-empty, extra-empty
When I created the database I used the default setting for the database type (MyISAM).
Thanks to anyone who can shed some light on this for me.
|