douji6940 2015-04-04 19:50
浏览 25
已采纳

无法使单选按钮检查工作(PHP)

I'm writing a small little webpage with 5 sickle cell anemia questions. I'm using the isset function to check the form elements and see if the user has selected a radio button for all 5 questions. But I cannot seem to make it work. What am I doing wrong?

<?php

    if (isset($_POST['q1','q2','q3','q4','q5'])) {
        echo 'Your score is <font size="24" color="red">' . $score . '</font> out of 100';
    }    else { 
        echo "Please answer all questions";
    }

?> 
  • 写回答

1条回答 默认 最新

  • doulingzhuang3079 2015-04-04 20:07
    关注

    You are not writing isset in correct way:-

        if (isset($_POST["q1"],$_POST["q2"],$_POST["q3"],$_POST["q4"],$_POST["q5"])) {
            echo 'Your score is <font size="24" color="red">' . $score . '</font> out of 100';
        }    else { 
            echo "Please answer all questions";
        }
    
    ?> 
    

    If not understandable or you want to know exactly how's it working then read isset and array manual please.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号