Hello. I am brand new to this forum and a REALLY wannabe (one day) php programmer. I have completed an introduction and intermediate php/mysql class and have completed several php tutorials. For the last two weeks, I have been searching for an answer to the following problem.
I need the checkbox or checkboxes a user clicks to update the database. Right now, it is recording the boxes checked but I am receiving the following errors on the boxes that are not checked:
[i]Notice: Undefined index: SM_03022012 in C:\wamp\032012SMwebinar\addreg.inc.php on line 21
Notice: Undefined index: FH_03062012 in C:\wamp\032012SMwebinar\addreg.inc.php on line 24
Your information has been successfully received. Thank you![/i]
Of course, the lines mentioned in the messages differ according to which boxes I check.
Here is my table structure.
Table name is smwebinar032012.
regid INT(11) auto-increment primary key
SM_02292012 VARCHAR(50)
SM_03022012 VARCHAR(5)
SM_03072012 VARCHAR(50)
FH_03012012 VARCHAR(50)
FH_03062012 VARCHAR(50)
FH_03082012 VARCHAR(50)
Here is my form on main.inc.php. I’ve removed all the html for easier reading:
<form action=index.php method=post>
Webinar 1
<input type="checkbox" name="check_list[]" value="Wednesday February 29, 2012 4:30 PM EST" > Wednesday February 29, 2012 4:30 PM EST
<input type="checkbox" name="check_list[]" value="Friday March 2, 2012 9:00 AM EST">Friday March 2, 2012 9:00 AM EST
<input type="checkbox" name="check_list[]" value="Wednesday March 7, 2012 1:30 PM EST">
Wednesday March 7, 2012 1:30 PM EST
Webinar2
<input type="checkbox" name="check_list[]" value="Thursday March 1, 2012 1:30 PM EST">Thursday March 1, 2012 1:30 PM EST
<input type="checkbox" name="check_list[]" value="Tuesday March 6, 2012 9:00 AM EST">Tuesday March 6, 2012 9:00 AM EST
<input type="checkbox" name="check_list[]" value="Tuesday March 8, 2012 4:30 AM EST">Tuesday March 8, 2012 4:30 AM EST
<input type="submit" value="Submit">
<input type="hidden" name="content" value="addreg">
</form>
And here is my addreg.inc.php file:
[php]<?php
$con = mysql_connect(“localhost”, “jude”,“j001”) or die(‘Sorry, could not connect to database server’);
mysql_select_db(“sales”, $con) or die(‘Sorry, could not connect to database’);
if (!$con)
{
echo “<h2 class=“BodyCopy”>Sorry, we cannot process your request at this time, please try again later\n”;
echo “<a href=“index.php?content=main” class=“BodyCopy”>Please try again
\n”;
exit;
}
$check_list[] = $_POST[‘check_list[]’];
//Everything passed, enter information in database
$result=mysql_query(“INSERT INTO smwebinar032012 VALUES(‘regid’, ‘check_list[]’)”);
$message = 'Invalid query: ’ . mysql_error() . “\n”;
die($message);
if (!$result)
{
echo “<h2 class=“BodyCopy”>Sorry, there was a problem processing your information
\n”;
echo “\n”;
echo "<table width=\"670\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n";
echo "<tr>\n";
echo "<td colspan=\"2\" bgcolor=\"#69670E\" class=\"Copyright\" align=\"center\">© 2012 Inc. All Rights Reserved</td>\n";
echo "</tr>\n";
echo "</table>\n";
exit;
} else
{
echo “<h2 class=“BodyCopy”>Your information has been successfully received. Thank you!
\n”;
echo “\n”;
echo "<table width=\"670\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\n";
echo "<tr>\n";
echo "<td colspan=\"2\" bgcolor=\"#69670E\" class=\"Copyright\" align=\"center\">© 2012 Inc. All Rights Reserved</td>\n";
echo "</tr>\n";
echo "</table>\n";
exit;
}
?>[/php]
Any and all guidance will be greatly appreciated.
I hope I haven’t entered too much information.