I have been unable to figure out how to insert data into My database. I am just learning PHP so please ignore comments
<?php
if (isset($_POST['submit']))
{
if (isset($_POST['question']))
{
$DBhost = "localhost";
$DBuser = "root";
$DBpass = "";
$DBName = "exit_poll";
$table = "exit_reason";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");
//@mysql_select_db("$DBName") or die("Unable to select database $DBName");
$conn = mysql_connect($DBhost,$DBuser,$DBpass) or die('Unable to connect to database'. mysql_error());
// echo 'Please select only 3 or less'
// $Qcount = count(question);
echo 'Please select only 3 or less';
foreach ($_POST['question'] as $value)
{
$sql="INSERT INTO exit_reason (date,$value) VALUES (now(),1)";
mysql_query($conn, $sql);
// $query=mysql_query ("INSERT INTO ($table) SET date = NOW(), (question) VALUE('1')"); SET date = NOW(),
echo $sql . '<br>';
}
}
else
{
echo 'Your Vote is Very Important to us.Please select at least 1 reason';
}
}
mysql_close($conn);
?>
any help is greatly appreciated