dongtiran7769 2012-10-10 17:39
浏览 121
已采纳

带有$ _GET函数的PHP代码不起作用,没有错误

I have written a simple PHP code:

<?php
    if (isset($_GET['day']) && isset($_GET['date']) && isset($GET['year'])) {
        $day = $_GET['day'];
        $date = $_GET['date'];
        $year = $_GET['year'];
        if (!empty($day) && !empty($date) && !empty($year)) {
            echo 'It is '.$day.' '.$date.' '.$year;
        } else {
            echo 'Fill in all fields.';
        }
    }
?>

<form action="index.php" method="GET">
    Day:<br><input type="text" name="day"><br>
    Date:<br><input type="text" name="date"><br>
    Year:<br><input type="text" name="year"><br><br>
    <input type="submit" value="Submit">
</form>

To me, everything looks OK. No errors after running. But, neither the output. Non of the echos shows up. Form is there and I enter data, but when I click "Submit", it just stays the same. URL of the page changes and I can see entered data there, but no echos on the page. I have checked the code for spelling errors, and I haven't found any. Thanks in advance.

  • 写回答

2条回答 默认 最新

  • dongwen3437 2012-10-10 17:41
    关注

    You forgot an underscore at this:

     if (isset($_GET['day']) && isset($_GET['date']) && isset($GET['year'])) {
    

    at the last get

     if (isset($_GET['day']) && isset($_GET['date']) && isset($_GET['year'])) {
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?