Help, INSERT (error)

wxdqz

New Member
I am having an issue.
I have a page of contact information
Name + E-mail.

I can have everything cycled through the tables and outputted onto the html page.
That works excellent.

What is giving me issues however, is the form.

Name: [ ]
Email: [ ]

Submit

User clicks submit, Gets an INPUT ERROR.

Here is the code.


<?

if (($REQUEST_METHOD=='POST')) {

for(reset($HTTP_POST_VARS);
$key=key($HTTP_POST_VARS);
next($HTTP_POST_VARS)) {
$this = addslashes($HTTP_POST_VARS[$key]);
$this = strtr($this, ">", " ");
$this = strtr($this, "<", " ");
$this = strtr($this, "|", " ");
$$key = $this;
}

if ($name && $email ) {
$query = "INSERT INTO contacts ";
$query .= "(contact_id, contact_name, ";
$query .= "contact_email, contact_time) ";
$query .= " values(0000,'$name','$email',NULL,)";
mysql_pconnect("localhost","user","pass")
or die("Unable to connect to SQL server");
mysql_select_db("database") or die("Unable to select database");
mysql_query($query) or die("Insert Failed!");

} else {
$notall = 1;
}
}
?>



I'll get the Insert Failed on the html page after clicking submit

*User/Pass/Database have been changed for this posting

I appreciate your response in helping me, as a newbie get my script working.
 
Back
Top