Hi, I`m newbie in php. I have this script, its no error. But no variabel was input into the database. Please Help.
This is the script :
<?
$id = $_POST['id1'];
$id2 = $_POST['id2'];
$sql = "INSERT INTO `mychoice` (`cek1`,`cek2`) VALUES ('".$id."','".$id2."')";
?>
<html>
<body>
<form action="cek.php" name="frm1" id="frm1" method="get">
<input name="id1" id="id1" type="checkbox" value="1">Test
<input name="id2" id="id2" type="checkbox" value="2">Test2
<label>
<input type="submit" name="Submit" value="Submit">
</label>
</form>
</body>
</html>
CheckBox Problem[Help] - Cannot insert to database
Moderator: General Moderators
Re: CheckBox Problem[Help] - Cannot insert to database
In your form, you set the method to "GET", but when you look for the variables you are looking at the "POST" array. Change one or the other.joola wrote:Hi, I`m newbie in php. I have this script, its no error. But no variabel was input into the database. Please Help.
This is the script :
<?
$id = $_POST['id1'];
$id2 = $_POST['id2'];
$sql = "INSERT INTO `mychoice` (`cek1`,`cek2`) VALUES ('".$id."','".$id2."')";
?>
<html>
<body>
<form action="cek.php" name="frm1" id="frm1" method="get">
<input name="id1" id="id1" type="checkbox" value="1">Test
<input name="id2" id="id2" type="checkbox" value="2">Test2
<label>
<input type="submit" name="Submit" value="Submit">
</label>
</form>
</body>
</html>
-
nowaydown1
- Forum Contributor
- Posts: 169
- Joined: Sun Apr 27, 2008 1:22 am
Re: CheckBox Problem[Help] - Cannot insert to database
In addition to what califdon mentioned, you're building a string with your SQL query, but I don't see any code to actually execute the query (mysql_query).
Re: CheckBox Problem[Help] - Cannot insert to database
Oops! I should have caught that, but I didn't!nowaydown1 wrote:In addition to what califdon mentioned, you're building a string with your SQL query, but I don't see any code to actually execute the query (mysql_query).