如何使用引导类警报显示成功消息PHP代码 [英] How to display success message PHP code with bootstrap class alert

查看:68
本文介绍了如何使用引导类警报显示成功消息PHP代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用PHP更新或插入记录时,我需要显示成功消息

I need to display Success Message while update or insert records in using PHP

这是我的HTML代码

<form action='a.php' methord='post'>
// alert message here
<div class="alert">
<a class="close" data-dismiss="alert"><i class="icon-remove"></i></a>
<strong><?php echo $message; ?></strong>
</div>
<input type="text" class="form-control" style="height:27px;" name="name"\>
<input type="email" class="form-control" style="height:27px;" name="email"\>
<input type="tel" class="form-control" style="height:27px;" name="mobile"\>
<input type="submit" name="user_details" class="btn btn-danger" value="Submit" />
</form>

Php代码(a.php):

Php Code (a.php):

if(isset($_POST['user_details']))
{
    $name = $_POST['name'];
    $email = $_POST['email'];
    $mobile= $_POST['mobile'];

    $sql = mysql_query("update user_details set name='$name', email='$email', mobile='$mobile'");
    if($sql==true)
    {
        $message = 'Success';
    }
    else
    {
        echo ''.mysql_error();
    }

}


推荐答案


HTML

HTML



<div class="form-group">
        <div class="col-sm-10 col-sm-offset-2">
            <?php echo $result; ?>    
        </div>
    </div>




PHP

PHP



 if ($error == false) {
$result='<div class="alert alert-success">Thank You! I will be in touch</div>';
}else {
    $result='<div class="alert alert-danger">Sorry there was an error sending your message. Please try again later</div>';
}

这篇关于如何使用引导类警报显示成功消息PHP代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆