I have an HTML form that inserts a record into my table / database. I get a successful echo and a new row appears in the table, but the fields are empty in the database.
What could I be doing wrong?
Here is my php code:
<?
$host="localhost";
$username="XXXXXX";
$password="XXXXXX";
$db_name="XXXXXX";
$tbl_name="cartons_current";
mysql_connect("$host", "$username", "$password") or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$order = "INSERT INTO cartons_current
(part_no, description, count, size, min, max, qty)
VALUES
('$part_no', '$description', '$count', '$size', '$min', '$max', '$qty')";
$result = mysql_query($order); //order executes
if($result){
echo("<br>Input data is succeed");
} else{
echo("<br>Input data is fail");
}
?>
Variables
$part_no,$descriptiondoesn’t appear magiacally (due to turned offregister_globals)So you need to use
$_GETor$_POSTarrays to retrieve the data ($_GET['part_no'], etc)PS: google something about sql injections