Good morning all,
I am using "PHP and MySQL Web Development" to develop an online form but have hit a snag. The code sort of kind of half works when run from within ActiveState Komodo (it writes blank records to the table) but does not work when called from the html page, Insert_ANSI.php is called but displays no message and writes nothing to mySQL. Below is what I have so far in php, I am hesitant to post the html (but have attached it) as it is generated by VisualStudio and is quite ugly, but consists of 3 fields and a submit button.
I tried replacing $HTTP_POST_VARS[] with $_POST_VARS[] but it made no difference.I also get "undefined index" warnings from the debugger but have been led to believe they can be safely ignored.
Any Hints?
TIA
Wayne McDermott
Insert_ANSI.php
<html>
<head>
<title>ANSI form</title>
</head>
<body>
<?php
// create short variable names
$ANSI_NO=$HTTP_POST_VARS['ANSI_NO'];
$ItemName=$HTTP_POST_VARS['ItemName'];
$Description=$HTTP_POST_VARS['Description'];
if (!$ANSI_NO || !$ItemName || !$Description)
{
echo 'Data not entered';
exit;
}
@ $db = mysql_pconnect('localhost', 'root', 'cilegon');
if (!$db)
{
echo 'Error, could not connect to database';
}
mysql_select_db('ansi');
$query = "insert into ansi values ('".$ANSI_NO."', '".$ItemName."', '".$Description."')";
$result = mysql_query($query);
if ($result)
echo mysql_affected_rows().' ANSI inserted into database.';
?>
</body>
</html>