dourong8495 2017-07-25 09:25
浏览 104
已采纳

PHP中的引导程序警报消息

I'm a little bit confused about alert messages in bootstrap and using them in my PHP code. I have an if/else statement and I want the alert success of bootstrap in my if statement block and also danger alert in an else statement block, kindly check my code.

if($mysqli->query($sql) == = true){
    echo '<div class="alert alert-success">Thank You!now please login </div>';
    header("location:login.php");

} else {

    echo '<script language="javascript">';
    echo 'alert("Registration Failed, Something Wrong With Your Details")';
    echo '</script>';
}
  • 写回答

3条回答 默认 最新

  • doutian4046 2017-07-25 10:04
    关注

    You can set it like

    <?php
    if($mysqli->query($sql) === true){
      echo '<div class="alert alert-success">Thank You!now please login </div>';
      header("Refresh: 3; URL=http://yoursite.com/login.php");
    }?>
    

    It will redirect user to login page after 3 seconds as Refresh: 3 is set.

    Click header: php manual

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?