<input name="Submit" type="submit" class="submitbtn" value="Submit" />
<?php if(isset( $_POST['Submit']) && $msg!='' ){?>
<div class="erroroutput"><p><?php echo $msg; ?><br></p></div>
<?php } else{?>
<div><center><h2>Thank you for submission</h2></center></div>
<?php }?>
</form>
成功提交后,我需要回复“谢谢你提交”。但在提交之前和之后回应。
仅供参考:同一页面上的表格行动
感谢输入的GUYS。 “决定
答案 0 :(得分:1)
你需要2个if语句,一个说“表单是提交吗?”,还有一个说“是否有错误信息?”
<input name="Submit" type="submit" class="submitbtn" value="Submit" />
<?php if(isset( $_POST['Submit']) {
if($msg!='')
{?>
<div class="erroroutput"><p><?php echo $msg; ?><br></p></div>
<?php } else{?>
<div><center><h2>Thank you for submission</h2></center></div>
<?php }
}?>
答案 1 :(得分:0)
像那样改变
<input name="Submit" type="submit" class="submitbtn" value="Submit" />
<?php if(isset( $_POST['Submit']) && $msg=='' )
{?>
<div><center><h2>Thank you for submission</h2></center></div>
<?php } else{?>
<div class="erroroutput"><p><?php echo $msg; ?><br></p></div>
<?php }?>
答案 2 :(得分:0)
试试这个,
使用两个条件。
<?php if(isset( $_POST['Submit'])
{
if( $msg!='')
{?>
<div class="erroroutput"><p><?php echo $msg; ?><br></p></div>
<?php } else{?>
<div><center><h2>Thank you for submission</h2></center></div>
<?php }
}?>
答案 3 :(得分:0)
你必须在你的else-if循环中检查提交任务。
用以下代码替换您的代码:
<input name="Submit" type="submit" class="submitbtn" value="Submit" />
<?php if(isset( $_POST['Submit']) && $msg!='' )
{?>
<div class="erroroutput"><p><?php echo $msg; ?><br></p></div>
<?php } elseif (isset( $_POST['Submit'])) { ?>
<div><center><h2>Thank you for submission</h2></center></div>
<?php }?>
</form>
答案 4 :(得分:0)
<input name="Submit" type="submit" class="submitbtn" value="Submit" />
<?php if(isset( $_POST['Submit']) && $msg!='' ){?>
<div class="erroroutput"><p><?php echo $msg; ?><br></p></div>
<?php } else if(isset($_POST['Submit]){?>
<div><center><h2>Thank you for submission</h2></center></div>
<?php }?>