Here is my code:
[code]<?PHP
session_start();
if (!(isset($_SESSION[‘login’]) && $_SESSION[‘login’] != ‘’)) {
header (“Location: vhindex.php”);
}
$tablename = $_SESSION[‘ID’]. “_hours”; //fetch contents of the table ID_hours
$user_name = “root”;
$password = “”;
$database = “authentication”;
$server = “127.0.0.1”;
$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);
$SQL = “SELECT * FROM $tablename”; //grab all the records from table
$result = mysql_query($SQL)
or die("" . "PLEASE REPORT THE FOLLOWING ERROR TO THE ADMINISTRATOR: " . “” . mysql_error());
if( isset($_POST['date1']) ){
$thedate = $_POST[‘date1’];
$thedes = $_POST[‘description1’];
$combo1 = $_POST[‘combo1’];
$SQL = "INSERT INTO $tablename (Date, Description, Hours) VALUES ($thedate, $thedes, $combo1)";
mysql_query($SQL);
}
while ( $db_field = mysql_fetch_assoc($result) ) {
print “” . (“Record ID:”) . " ";
print $db_field[‘ID’] . " ";
print “” . (“Date:”) . " ";
print $db_field[‘Date’] . " ";
print “” . (“Description:”) . " ";
print $db_field[‘Description’] . " ";
print “” . (“Duration:”) . " ";
print $db_field[‘Hours’] . “
”;
}
?>[/code]
Unfortunately, when the submit button is pressed, the data is not added to the database despite this code:
if( isset($_POST['date1']) ){
$thedate = $_POST['date1'];
$thedes = $_POST['description1'];
$combo1 = $_POST['combo1'];
$SQL = "INSERT INTO $tablename (Date, Description, Hours) VALUES ($thedate, $thedes, $combo1)";
mysql_query($SQL);
}
Can anybody offer any suggestions?