Hi all,
I'm having a problem inserting data from a web interface I created into a database.
Please could you help me out here...
Here is my php code...
?php
// create short variablle names
$const = $HTTP_POST_VARS['const'];
$name = $HTTP_POST_VARS['name'];
$email = $HTTP_POST_VARS['email'];
$party =$HTTP_POST_VARS['party'];
if (isset($HTTP_POST_VARS['submit'])) {
echo 'submitted';
} else {
echo 'error';
}
if (!$const || !$name || !$email || !party)
{
echo 'You have not entered all the details.<br>
<a href="candidate.htm">Return to fill in details</a>';
exit;
}
$const = addslashes($const);
$name = addslashes($name);
$email = addslashes($email);
$party = addslashes($party);
@$db = mysql_pconnect('localhost', 'root', 'ballY22');
if (!$db)
{
echo 'Error: Unable to connect to database';
exit;
}
mysql_select_db('trial'); // db name
$query = "insert into candidate values
(NULL, '".$const."', '".$name."', '".$email."', '".$party."')";
$result = mysql_query($query)
if ($result)
echo mysql_affected_rows().' details inserted into database.';
?>
Here are my database details...
candidateID int(10) UNSIGNED Not Null auto_increment Primary Key
name varchar(40) Not Null
email varchar(100) Not Null
party varchar(5) Not Null
Everything seems to work fine until I reach the insert into database part.
I am very grateful for your help and time.
Thank you.
Kevin.