Page 1 of 1

Checkbox save into phpmyadmin and then retrieve

Posted: Sun Jan 22, 2012 12:06 am
by ShadowSkill
I'm confused, i have been trying all sorts of stuffs to my codes...

Code: Select all

<form  method="post">
<input type="checkbox" name="1BC1" value="DPEM 101 Philosophy of Man" />DPEM 101 Philosophy of Man 3 units
<input type="checkbox" name="1BC2" value="DPEM 101 Philosophy of Nature" />DPEM 101 Philosophy of Nature 3 units
<input type="checkbox" name="1BC3" value="DPEM 101 Philosophy of Earth" />DPEM 101 Philosophy of Earth 3 units
<input type=Submit value="Submit" name="stdsubmit">

<?

if(isset($_GET["stdnum"]))
{
		
	
$database="stdrecords";


$1BC1=$_GET['1BC1'];
$1BC2=$_GET['1BC2'];
$1BC3=$_GET['1BC3'];


mysql_connect("localhost","root","");

@mysql_select_db($database) or die( "NO DATABASE");


$query = "INSERT INTO stddeg (1BC1,1BC2,1BC3) VALUES('','$1BC1','$1BC2','$1BC3')";
mysql_query($query);


  header("Location: saved.php");

mysql_close();
}


?>




Re: Checkbox save into phpmyadmin and then retrieve

Posted: Sun Jan 22, 2012 6:35 am
by Celauran
I don't see stdnum defined anywhere in the code you posted, so your $_GET['stdnum'] condition may never be true. Even if it is, variable names cannot start with a number so your insert query will fail.