HTML表单/不完整的POST请求

HTML表单/不完整的POST请求,html,forms,post,Html,Forms,Post,(这听起来太不可思议了——但我的验证样本…) 我有一个带有三个输入控件的表单,提交表单时,POST数据中只包含复选框(取自Chrome的Inspect/“Network”-选项卡): 不幸的是,表单本身并不是最简单的——它被嵌入到各种其他控件中,并且包含一个表,该表保存HTML,但是验证——我检查过了。) 相关控件的代码(都在表格中的表格中)为: 我现在花了好几个小时和他在一起——也许我只是看了太多的代码而看不到简单的解释 p.S:是的,我承认-布局/设计远不是最优的,但我主要关心的是

(这听起来太不可思议了——但我的验证样本…)

我有一个带有三个输入控件的表单,提交表单时,POST数据中只包含复选框(取自Chrome的Inspect/“Network”-选项卡):

不幸的是,表单本身并不是最简单的——它被嵌入到各种其他控件中,并且包含一个表,该表保存HTML,但是验证——我检查过了。) 相关控件的代码(都在
表格
中的
表格
中)为:

我现在花了好几个小时和他在一起——也许我只是看了太多的代码而看不到简单的解释


p.S:是的,我承认-布局/设计远不是最优的,但我主要关心的是如何满足要求…;-)

看起来您只给了复选框一个“名称”(name=“mail”)。你还需要给其他人起个名字。“name”是PHP中用来访问输入值的内容

<input value="" type="text" id="rec" name="rec">
<input type="checkbox" value="mail" id="mail" name="mail" onclick="bs(this)">
<textarea value="" rows="10" cols="80" id="txt" name="txt"></textarea>

看起来您只给了复选框一个“名称”(name=“mail”)。你还需要给其他人起个名字。“name”是PHP中用来访问输入值的内容

<input value="" type="text" id="rec" name="rec">
<input type="checkbox" value="mail" id="mail" name="mail" onclick="bs(this)">
<textarea value="" rows="10" cols="80" id="txt" name="txt"></textarea>

当您创建一个HTML表单时,请求中发送的不是元素的id,而是名称:

要获取所有输入元素,可以在其他输入中添加名称,如下所示:

<form method="post" action=""> <!-- method == 'post' or 'get' -->
    <input value="" type="text" id="rec" name="rec" >
    <input type="checkbox" value="mail" id="mail" name="mail" onclick="bs(this)">
    <textarea value="" rows="10" cols="80" id="txt" name="txt"></textarea>
</form>
并(使用php)获取“get”方法:

$myRec = $_POST['rec']; // get the element with the name 'rec'
$myMail = $_POST['mail']; // get the element with the name 'mail'
$mytxt = $_POST['txt']; // get the element with the name 'txt'
$myRec = $_GET['rec']; // get the element with the name 'rec'
$myMail = $_GET['mail']; // get the element with the name 'mail'
$mytxt = $_GET['txt']; // get the element with the name 'txt'

这将在官方W3.org上解释。

当您创建HTML表单时,请求中发送的不是元素的id,而是名称:

要获取所有输入元素,可以在其他输入中添加名称,如下所示:

<form method="post" action=""> <!-- method == 'post' or 'get' -->
    <input value="" type="text" id="rec" name="rec" >
    <input type="checkbox" value="mail" id="mail" name="mail" onclick="bs(this)">
    <textarea value="" rows="10" cols="80" id="txt" name="txt"></textarea>
</form>
并(使用php)获取“get”方法:

$myRec = $_POST['rec']; // get the element with the name 'rec'
$myMail = $_POST['mail']; // get the element with the name 'mail'
$mytxt = $_POST['txt']; // get the element with the name 'txt'
$myRec = $_GET['rec']; // get the element with the name 'rec'
$myMail = $_GET['mail']; // get the element with the name 'mail'
$mytxt = $_GET['txt']; // get the element with the name 'txt'

这将在官方W3.org上解释。

aaaaaargh-它必须在我耳朵之间的某个地方!;-)我完全忽略了这一点-谢谢((Aaaaargh-一定是在我耳边的某个地方!;-)我完全忽略了这一点-谢谢!:((谢谢医生-这解释了一切!(我接受了遗嘱执行人的回答,因为他快了一点,所以当你的回答来时我已经哭了……;-))没什么大不了的:p!关键是你解决了你的问题!w3.org是HTML中的官方组织。文档非常有用!!谢谢医生-这解释了一切!(我接受了执行者的回答,因为他快了一点,所以当你的回复来时我已经哭了…;-))没什么大不了的:p!关键是你解决了你的问题!w3.org是HTML的官方组织。文档非常有用!!