<?php if($_POST['submit']){
echo "登入成功";
}
?> <form action="login.php" method="post" enctype="text/plain">
用户名:<input type="text" name="user" size="10">
密码:<input type="password" name="pass" size="10">
<input type="submit" name="submit" value="登入" size="10">
</form> 点击登入后没有显示“登入成功”,这是为什么呢?小弟刚学php,望高手赐教!
echo "登入成功";
}
?> <form action="login.php" method="post" enctype="text/plain">
用户名:<input type="text" name="user" size="10">
密码:<input type="password" name="pass" size="10">
<input type="submit" name="submit" value="登入" size="10">
</form> 点击登入后没有显示“登入成功”,这是为什么呢?小弟刚学php,望高手赐教!
$_POST['submit']改成$_SERVER['REQUEST_METHOD'] == 'POST' 试试
在if($_POST['submit'])前加了print_r($_POST);输出Array() 这是什么意思呢?
还有个问题:输出Array()是在我点击“登入”前就有了,这是为什么呢?还没提交表单哪来$_POST?
$_POST是系统预定义的数组变量,你没有点登陆,只是没有往$_POST里面写值,但是$_POST已经存在了。多看看PHP手册。
把提交类型去掉 enctype 试试。
<?php
//这一行添加session_start();试试
action="mailto:[email protected]?subject=Testing submit"
enctype="text/plain" >Please fill in your name:
<input type=text size=20 name="Visitor" > <p>Please fill in your telephone number:
<input type=text size=20 name="Tel" > <p><input type=submit value="Submit information" >
<input type=reset value="Clear filled data" >
</form>
</body> </html>
在发送前编码所有字符(默认)multipart/form-data
不对字符编码。
在使用包含文件上传控件的表单时,必须使用该值。text/plain
空格转换为 "+" 加号,但不对特殊字符编码。(用$_REQUEST应该能取到值)