我想创建简单的投票调查而不点击按钮,但它不起作用

时间:2017-02-10 19:19:13

标签: php mysql mysqli

这是vote.php whitch位于上传,当我需要vote.php整个内容消失...

<?php 
require 'db.php';
    $yesOrNo=$_POST['yesOrNo'];
if(isset($_POST['yesOrNo'])){
    header('location:index.php');
    if(!empty($yesOrNo)){
        $sqlv=$con->query("INSERT INTO votepoll (yesorno) VALUES ('{$yesOrNo}')");
    if($sqlv){


    }
    else{
        header('location:index.php');
    }
 }
}
?>

这是user.php中的表格

<form>
<input type="radio" name="yesOrNo" value="yes"><span style="font-family:none;font-size:22px">YES</span>
<input type="radio" name="yesOrNo" value="no"><span style="font-family:none;font-size:22px">NO<br>
</form>

1 个答案:

答案 0 :(得分:0)

缺少表单方法,php代码没问题。

<form method="POST">
<input type="radio" name="yesOrNo" value="yes"><span style="font-family:none;font-size:22px">YES</span>
<input type="radio" name="yesOrNo" value="no"><span style="font-family:none;font-size:22px">NO<br>
</form>