Php 有条件设置表单提交操作
试试这个Php 有条件设置表单提交操作,php,forms,Php,Forms,试试这个 <form action="<?php if(isset($redirect)&& $redirect == "f"){echo "#";} else{ ?>add_new_item2.php?user_id=<?php echo $_GET['user_id']; }?>" method="post"> //no need to expose this area here <input type="submit" valu
<form action="<?php if(isset($redirect)&& $redirect == "f"){echo "#";}
else{ ?>add_new_item2.php?user_id=<?php echo $_GET['user_id']; }?>" method="post">
//no need to expose this area here
<input type="submit" value="submit" name="submit" />
</form>
//the processor
<?php
if(isset($_POST['submit']))
{
$redirect = "f";
if(whatever)
{
//the if condition comes here
}
else //all if conditions are satisfied
{
$redirect = "t";
}
}
如果已设置重定向值。使用$\u服务器['PHP\u SELF']
对当前页面执行操作
检查引号$redirect==“f”
。它应该是单引号或转义正确
<?php
$action = '';
if(isset($redirect) && $redirect == "f") {
$action = "#";
} else {
$action = "add_new_item2.php?user_id=".$_GET['user_id'];
}
?>
<form action="<?php echo $action; ?>" method="post">
您在使用前设置条件意味着
<form name="form1" method="post"
action="<?php
if(isset($redirect)&& $redirect == 'f'){echo $_SERVER['PHP_SELF'];}
else{ echo 'add_new_item2.php?user_id='.$_GET['user_id']; }
?>"
>
尝试在双引号前后加单引号。与此类似:
<?php
$action = '';
if(isset($redirect) && $redirect == "f") {
$action = "#";
} else {
$action = "add_new_item2.php?user_id=".$_GET['user_id'];
}
?>
<form action="<?php echo $action; ?>" method="post">
(值='“x”)
希望这有助于……如何设置$redirect
值?我想您需要JavaScript。查找服务器端和客户端之间的差异。哦,我的代码有它自己的错误,$redirect=“f”应该在isset之外($_POST['submit']),然后添加Pragnesh Chauhan的答案:)我希望这个问题有帮助:)哦,是的,我没有想到这一点,我真的有很多想法,我很忙,这是一个很好的答案,布拉格尼什·乔汉,我认为这是最好的答案,我要感谢你:)虽然$redirect==“f”应该是$redirect==“t”,但谢谢你,这是一个很大的帮助:)
<input type=label name=\"Description1\" value='". $T_Description. "' style=\"width:650px; margin-left:50px; padding: 5px;\" \>