Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 带有“提交”按钮的表单,该按钮导致另一个带有“是/否”按钮的表单_Php_Html_Forms - Fatal编程技术网

Php 带有“提交”按钮的表单,该按钮导致另一个带有“是/否”按钮的表单

Php 带有“提交”按钮的表单,该按钮导致另一个带有“是/否”按钮的表单,php,html,forms,Php,Html,Forms,使用php当我按下submit按钮将数据发送到服务器时,当脚本返回时,我需要显示yes和no按钮来批准或取消批准发送的数据…请帮助!我在if/else if语句中迷路了 if (filter_has_var(INPUT_POST, "office")){ $office = filter_input(INPUT_POST, "office"); print "<span>, your office is room $office</span>"; } if (filt

使用php当我按下submit按钮将数据发送到服务器时,当脚本返回时,我需要显示yes和no按钮来批准或取消批准发送的数据…请帮助!我在if/else if语句中迷路了

if (filter_has_var(INPUT_POST, "office")){

$office = filter_input(INPUT_POST, "office");
print "<span>, your office is room $office</span>";
}

if (filter_has_var(INPUT_POST, "os")){
$os = filter_input(INPUT_POST, "os");
print "<span>, and your OS is $os</span>";
}

if($_POST['submit']== 'yes'){
    echo "Thanks!";
}elseif($_POST['submit']=='no'){
    return form(); 
}

else{

//there's no input. Create the form 

print <<< HERE
<form action ="" method="post">
<fieldset>
<label>Enter your name</label> 
<input type = "text"
         name = "name"/><br>
<label>Employee ID</label> 
<input type = "text"
         name = "id"/><br>
<label>Office Room Number</label> 
<input type = "text"
         name = "office"/><br>
<label>Oberating System on the Office Computer</label> 
<input type = "text"
         name = "os"/><br>

<input type="submit" name="submit" value="submit">
<input type="hidden" name="yes" value="yes">
<input type="hidden" name="no" value="no">
</fieldset> 
</form>
HERE;
}
// end 'value exists' if
?>
    </body>
</html>
if(过滤器有变量(输入后,“办公室”)){
$office=过滤输入(输入后,“办公室”);
打印“您的办公室是$office房间”;
}
如果(过滤器有变量(输入后,“操作系统”)){
$os=过滤输入(输入后,“os”);
打印“,您的操作系统为$OS”;
}
如果($_POST['submit']=='yes'){
回声:“谢谢!”;
}elseif($_POST['submit']=='no'){
返回表单();
}
否则{
//没有输入。请创建表单

打印您需要分三步执行此操作,而不是两步:

if (yes or no are set as well as the other required form variables){
   // step 3
   // do final submission
} else if (submit and other required form variables are set){
   // step 2
   // A. display data. 
   // B. display form with only yes/no options and no other visible fields
   // C. in form also include original submitted data (as hidden fields)
} else {
   // step 1
   // display empty form with all fields and a submit button
}

如果希望表单可编辑,您可以将第二步更改为组合A和C。

在将数据发送到服务器之前批准/不批准数据是否会更好,以便用户有机会更改数据的内容?我需要使用特定的用户输入填写表单,如姓名、emp ID ex。一旦我按下“提交”,但要发送数据,服务器应该让该数据再次出现在名称旁边,empID ex和我应该有一个“是”和“否”按钮来批准该数据。我只是不知道如何让我的“是/否”按钮出现在表单上。我同意gagrif的意见,这应该在提交之前完成,而不是之后,否则你必须重新发送相同的请求,这是错误的有点毫无意义。我感谢你们的帮助…我想我只是真的很困惑如何添加一个按钮太隐藏了form@DanWitts您不需要隐藏表单。您只需要隐藏字段。您的提交按钮不应该隐藏。例如,在步骤1中,不应该有任何“是”或“否”按钮(甚至不应该是隐藏的按钮)。所有按钮应为“提交”类型,而不是“隐藏”类型。因此,在步骤2中,您可以有两个提交按钮,每个按钮的“是”和“否”名称不同,或者有一个“提交”按钮,该按钮带有“是”或“否”单选按钮选项。