打开“使用"模态窗口.的PHP [英] Opening a Modal Window "using" PHP

查看:47
本文介绍了打开“使用"模态窗口.的PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用PHP创建一个登录系统,并且试图使其变得更好一点.

I am creating a log in system in PHP and I'm trying to make it a little nicer.

注销后,您将重定向回index.php.像这样:

When you log out, you get redirected back to index.php. Like this:

header("loaction: index.php?logout=true")

这使网址看起来像www.mysite.com/index.php?logout=true.然后,我使用以下代码:

This makes the url look like www.mysite.com/index.php?logout=true. I then use the following code:

if(isset($_GET['logout'])) {

$logoutvalue = $_GET['logout'];

if($logoutvalue = "true") {
$notification = "You've been logged out!";  
}

从URL获取注销的值并对其进行处理.

to get the value of logout from the URL and do something with it.

我有一个小的弹出窗口,它将显示通知变量的值.在这种情况下,它是您已注销!"我的问题是,如何在页面加载以及url等于/index.php?logout=true时显示模式窗口?

I have a small popout window that will display the notification variable's value. In this case it's "You've been logged out!" My question is how do I get the modal window to display when the page loads and when the url equals /index.php?logout=true ?

非常感谢所有评论,答案和建议!

All comments, answers, and suggestions are greatly appreciated!

谢谢! -瑞安(Ryan)

Thanks! - Ryan

推荐答案

我知道这是一篇过时的文章,但是为了将来帮助某人进行类似的任务,我认为以下内容可能有助于正确的方向(我已经测试下面的代码是我自己编写的,因此请进行调整).

I know it is an old post, but to help someone in future with similar quest, I guess the following may help to get into right directions ( I have tested the below code myself, so please make adjustment).

<?php if(isset($_GET['logout']) && $_GET['logout'] === 'true'){
        $message = "You've been logged out!";
    ?>
        <script>
        $(function() {
         $('#myModal').modal('show');
        });
        </script>

    <div class="modal fade" id="myModal" role="dialog">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <h4 class="modal-title">Edit Data</h4>
                </div>
                <div class="modal-body">
                    <div class="fetched-data"><?php $message ?></div> 
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                </div>
            </div>
        </div>
    </div>

    <?php } ?>

这篇关于打开“使用"模态窗口.的PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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