0

hi, ive made 2 pages, which have the form.html page and check.php page. data from form page into check page into database but having problem.

FORM.HTML

<body>
<form id="form1" name="form1" method="post" action="check.php">
<input type="checkbox" name="subject[]" value="WD">Web Design <br />
<input type="checkbox" name="subject[]" value="PH">PHP <br />
<input type="submit" name="submit" value="submit">
</form>
</body>

CHECK.PHP

<?php 
	$con = mysql_connect("localhost","root","");
	if (!$con) 
	{
		die('Could not connect: ' . mysql_error());
	}

	mysql_select_db("checkbox", $con);
	//insert to the table

$sql="INSERT INTO test VALUES('','$_POST[subject[0]]','$_POST[subject[1]]')";
if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "CheckBox value succesfully added";

mysql_close($con)
?>

WHAT I WANT !! IS TO INSERT THE VALUES OF THE CHECKBOXES INTO DATABASE.

1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by khushhappy
0

I have the database field as id,subject .
after running down, it shows the error pasted below:-
Parse error: parse error, expecting `']'' in C:\wamp\www\checkboxes\check.php on line 11

Kindly make certain possible running code with errors mentioned .

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.