不会回应新用户欢迎款

时间:2014-03-31 14:27:07

标签: php welcome-file

请在此提出任何建议或意见:

的login.php

<td width="65%" align="left">
    <input name="student_id" 
           type="text" 
           id="student_id" action="Student_Home.php" method="post">
</td>

Student_Home.php

<p>Welcome <?php echo $_POST["student_id"];?> </p>

输出:

  

欢迎通知:未定义索引:student_id in   第44行的C:\ xampp \ htdocs \ a \ Student_Home.php

期望的输出:欢迎“student_id”!!!

2 个答案:

答案 0 :(得分:0)

在以字面方式提问时,也许你的意思是:

<p>Welcome <?php echo "student_id";?> </p>

或者,如果你真的引用了"student_id"发布的一些id字符串,那么你必须检查该成员实际 是否存在于$ _POST变量中。你得到的错误表明目前它 ...是否可以使用GET方法发送html表单?然后你必须显然使用$_GET['student_id'] ...最好的方法是检查$ _POST和$ _GET中实际包含的内容,方法是将它们转储到某个日志文件中......

啊,现在通过编辑,我们可以看到您的HTML代码中存在问题:<input>标记提供操作和方法属性本身!您必须将该标记括在一个开头和一个结束<form>标记中,该标记可能带有该方法信息本身。所以你可能正在寻找这样的东西:

<form action="Student_Home.php" method="post">

    <td width="65%" align="left">
        <input name="student_id" 
               type="text" 
               id="student_id">
    </td>

</form>

另外还有一个简短的说明:这看起来像是在使用html表进行页面布局。这不是一个很好的做法,尽管有 有意义的例外情况。一般来说,你应该使用样式进行页面布局,所以改为使用css语言。这样可以保持页面的样式,并允许非标准浏览器更好地解释,这对于残疾用户来说非常重要。

答案 1 :(得分:0)

您似乎忘记添加FORM元素。在Login.php中尝试这个:

<td width="65%" align="left">
    <form action="Student_Home.php" method="post">
        <input name="student_id" 
                   type="text" 
                   id="student_id">
    </form>
</td>