我尝试通过php更新我的数据库,但数据库没有更新。
这是我的HTML代码:
<form method=post>
<input type="radio" name="osis" value= 1 >Nadiya<br>
<input type="radio" name="osis" value= 2 >Hafizh<br>
<input type="radio" name="osis" value= 3 >Aina<br>
<input type="submit" value="Submit">
<?php
if(isset($POST['osis'])){
$value = $_POST['osis'];
if($value == 1){
mysql_query('UPDATE kandidat_osis SET vote = vote + 1 WHERE id = 1');
}
else if($value == 2){
mysql_query('UPDATE kandidat_osis SET vote = vote + 1 WHERE id = 2');
}
else if($value == 3){
mysql_query('UPDATE kandidat_osis SET vote = vote + 1 WHERE id = 3');
}
mysql_close($conn);
}
?>
</form>
但我根本无法解决它,我搜索互联网和搜索引擎,但数据库仍未更新
答案 0 :(得分:0)
请注意,您在if(isset($POST['osis']))
$_POST
答案 1 :(得分:-2)
使用name作为Array或提供不同的名称
<?php if(isset($POST['osis'])){
$value = $_POST['osis'];
if($value == 1){
mysql_query('UPDATE kandidat_osis SET vote = vote + 1 WHERE id = 1');
}
else if($value == 2){
mysql_query('UPDATE kandidat_osis SET vote = vote + 1 WHERE id = 2');
}
else if($value == 3){
mysql_query('UPDATE kandidat_osis SET vote = vote + 1 WHERE id = 3');
}
mysql_close($conn);}
?>
<form method=post>
<input type="radio" name="osis[]" value= 1 >Nadiya<br>
<input type="radio" name="osis[]" value= 2 >Hafizh<br>
<input type="radio" name="osis[]" value= 3 >Aina<br>
<input type="submit" value="Submit">
</form>