dongwen1935 2013-04-24 07:39
浏览 221
已采纳

$ _POST ['变量'],变量无法识别(“未定义索引”)[关闭]

I am trying to learn PHP (just a tiny bit for a tiny project). I am trying to follow this tutorial, but when I do, it does not work. First of all I coppied the exact code there and it still did not work, but here is some of my code:

    <?php
         if($_POST['projectSubmit'] == "Submit") 
        {
            $toApprove= $_POST['projectName'];
        }
    ?>


    <form action ="getData" method="post" >
        <input type="text" name="projectName">
        <input type="submit" name="projectSubmit" value="Submit">
    </form>

Yet I get an error:

A PHP Error was encountered

Severity: Notice

Message: Undefined index: projectSubmit

Filename: views/ViewProjectApproval.php

Line Number: 13

What am I doing wrong ?

BTW: Is this a correct way of transmitting data back to my controller ? (model view controller with code igniter)

  • 写回答

2条回答 默认 最新

  • douluan8828 2013-04-24 07:41
    关注

    Use this

    if (isset($_POST['projectSubmit']) && $_POST['projectSubmit'] == "Submit") 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部