I have recently been having problems in inserting data to a table in a mysql database with the data obtained from a HTML form. Having browsed other similar topics in this forum I have managed to find a workaround, one that almost works. However I have two issues:
Array () appears at the tope of the page, and when data is submitted the contents of the array are shown. Can anyone suggest how I may remove this?
When running this code for the first time, a blank record is created along with the actual desired record. If the blank record remains then no further blank records are produced. If I remove the blank record and run the code again another blank record is created as well as the desired record. Has anybody experienced this before and is there a way I can sort this out?
I have included the code below, and any help would be appreciated. Thanks
<?php
print_r($HTTP_POST_VARS);
$dbconnection = mysql_connect("localhost","root","koala") or die ( 'No connection to the database made because: ' . mysql_error());
mysql_select_db("hrtrans") or die (mysql_error());
$result = mysql_query ("INSERT INTO transportorg (name,address,website,transporttype) VALUES ('" . $HTTP_POST_VARS[name] . "','" . $HTTP_POST_VARS[address] . "','" . $HTTP_POST_VARS[website] . "','" . $HTTP_POST_VARS[transporttype] . "')", $dbconnection);
mysql_close($dbconnection);
?>