I wanted to save the checkboxes to the database with a ready code. But I am having a problem and I couldn't handle it even though I tried a lot of things.I leave it here to ,php and html codes for you.This is the error:
input
PHP Fatal error: Uncaught Error: Class 'mysqli' not found in /home/main.php:3
Stack trace:
#0 {main}
thrown in /home/main.php on line 3
<?php
$conn = mysqli('localhost', 'root', '','testdemo') or die("not connect");
if(isset($_POST['submit'])){
$check=implode(',',"$_POST,[ch]");
$country=$_POST["country"];
$sql =$db->query("INSERT INTO 'test' ('checkbox','country')VALUES('$check','$country')");
if($qry>0){
echo '<script> alert("Data is submited");</script>';
}else{
echo '<script> alert ("Data is not submited");</script>';
}
}
?>
<html>
<head>
<title>Demo</title>
</head>
<body>
<form action="" method="POST">
<input type="checkbox" name="ch[]" value="PHP" /> PHP<br>
<input type="checkbox" name="ch[]" value="JAVA" /> JAVA<br>
<input type="checkbox" name="ch[]" value="CSS" /> CSS<br>
<input type="checkbox" name="ch[]" value="HTML" /> HTML<br>
<input type="checkbox" name="ch[]" value="CORE PHP" />CORE PHP<br>
<select name="country">
<input type="submit" name="send" value="Gönder" />
</form>
</body>
</html>