Checkbox save into phpmyadmin and then retrieve

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ShadowSkill
Forum Newbie
Posts: 22
Joined: Sun Jan 01, 2012 5:45 am

Checkbox save into phpmyadmin and then retrieve

Post 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();
}


?>



User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Checkbox save into phpmyadmin and then retrieve

Post 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.
Post Reply