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{?>
        <div><center><h2>Thank you for submission</h2></center></div>
<?php }?>
</form>

提交成功后需要回显“Thank you for submit”。但在提交前后回响。

仅供参考:同一页面上的表单操作

感谢大家的输入。解决了

4

5 回答 5

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 }
    }?>

于 2014-03-03T12:34:45.443 回答
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 }?>
于 2014-03-03T12:33:16.233 回答
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 }
     }?>
于 2014-03-03T12:34:38.263 回答
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>
于 2014-03-03T12:35:01.373 回答
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 }?>
于 2014-03-03T12:35:58.700 回答