I want to insert the selected data into my database but I am keep getting an error message saying:
"Undefined index: checkbox".
<?php
$con=mysqli_connect("localhost","root","","sgptt");//database connection
[B]$checkbox=$_POST['checkbox'];[/B]
if($_POST["submit"]== "submit"){
for ($i=0; $i<sizeof($checkbox); $i++){
$order = "INSERT INTO studentlist
(name,username)
VALUES
('$_POST[name]','".$checkbox[$i]."')";
$result = mysqli_query($con,"SELECT * FROM studentlist"); //order execute
if(!mysqli_query($con,$order)){
die('Error:'. mysqli_error($con));
}
header('Location:addStudent.php?Message=Group Successfully Added');
exit();
}
}
//echo $_POST["GroupName"];
?>