enctype="text/plain" 时 method="post" ,PHP 接收不到表单值,改成method="get" 可以
是何原因?<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body><div>
<form action="index.php" method="get" enctype="application/x-www-form-urlencoded" target="_self" id="loginForm">
用户:<input id="Uid" name="Uid" type="text" /><br>
密码:<input id="PSW" name="PSW" type="password" />
<input type="submit" value="提交">
</form>
</div>
<?php
echo('hello,now it is '.date('H:i:s,jS F,Y').'<br />');
echo('Uid:'.$_REQUEST['Uid'].' PSW:'.$_REQUEST['PSW']);
?></body>
</html>
解决方案 »
- mysql, id = $GET['id'] 返回结果为空。
- CKEditor 3.x 和ckfinder整合后出现的权限问题
- 数组组合
- 刚学php,在往mysql插入数据时的问题
- Warning: Smarty error: unable to read resource: "" in /var/vhost/zsti/www/lib/Sm
- 谁来给我解说一下php中面向对象的思想?
- 关于在PHP页面上显示图片的问题
- 求 iconv遇到特殊字符错误解决方案
- 在PHP中处理一个表单里多个提交按钮的问题——精解!
- php一个文件太大,想将其分成两部分写入两个文件
- 关于html+css的一个小问题
- 关于如何php给键值对数组增加一个新的键值对?
............................
</form>
传送方式有:
method="get" 表单数据会被视为CGI或ASP的参数发送.用户输入的数据会附加在URL之后,由用户端直接发送至服务器,所以速度上会比post快,缺点:数据长度不能太长.没有指定method 时.get为默认值.
method="post" 表单数据是与URL分开发送的.用户端会通知服务器来读取数据,所以没有数据长度上的限制,缺点:速度上会比get慢.
<form action="mailto:[email protected]" name="ixox" method="post"></form>
编码方式____________enctype
语法:<form enctype="编码方式">
.......................
</form>
说明表单信息提交的编码方式:
entype值
text/plaim ----------------以纯文本的形式传送
application/x-www-rorm-r\urlencoded -------------默认的编码形式
multipart/form-data -------------- MIME编码,上传文件的表单必须选择该项
用request.getInputStream()来接收流数据吧
echo file_get_contents("php://input");
?>
<form method="post" enctype="text/plain" target="_self" id="loginForm">
用户:<input id="Uid" name="Uid" type="text" /><br>
密码:<input id="PSW" name="PSW" type="password" />
<input type="submit" value="提交">
</form>
我的问题是 enctype="text/plain" , method="post" 时,PHP获取不到表单值
如果坚持使用 enctype="text/plain" ,要修改为 method="get" ,想知道原因,是 PHP就这样的,还是我的 服务器设置有问题,至于这几个值的含义我知道的,
纯文本方式传递表单值post就获取不到,不是这样的吧
echo file_get_contents("php://input");
?> 可以获取值没错但我想知道 enctype="text/plain" , method="post" 时 $_POST()为何接收不到数据
因为我网上搜索了半天没看到有人说这是不可以的
是不是我的服务器设置有问题
text/plaim ----------------以纯文本的形式传送
既然是“纯文本”,那就不能编码了。所以php就无法解析了另外你说 改成method="get" 可以 是错误的
<form action="index.php" method="get" enctype="text/plain" target="_self" id="loginForm">
用户:<input id="Uid" name="Uid" type="text" /><br>
密码:<input id="PSW" name="PSW" type="password" />
<input type="submit" value="提交">
</form>
</div>
<?phpecho('hello,now it is '.date('H:i:s,jS F,Y').'<br />');
echo('Uid:'.$_GET['Uid'].' PSW:'.$_GET['PSW'].'<br />');?>可以,代码没测试过我不会跑这里来问的另外我用的是 PHP5.3不知是否有本版的问题
<form action="index.php" method="post" enctype="text/plain" target="_self" id="loginForm">
用户:<input id="Uid" name="Uid" type="text" /><br>
密码:<input id="PSW" name="PSW" type="password" />
<input type="submit" value="提交">
</form>
</div>
<?phpecho('hello,now it is '.date('H:i:s,jS F,Y').'<br />');
echo('Uid:'.$_POST['Uid'].' PSW:'.$_POST['PSW'].'<br />');?>这样写不可以
text/plain 窗体数据以纯文本形式进行编码,其中不含任何控件或格式字符。
GET方法可以因为url已经存在参数所以行。