我正在寻找一种安全的方法,如果用户点击指向受保护内容的链接,则会在当前页面上显示弹出登录窗口。
我当然有一个login.php页面,其中包含一个隐藏的表单和一个javascript函数,可以在调用时使表单可见
然后在加载受保护的内容页面时,我调用此javascript函数来显示登录表单。
在表单提交上,表单调用另一个名为checklogin.php的php页面,该页面具有mysql检查,如果在db中找到用户,则设置会话变量'loggedin'。
当前的问题是在checklogin页面上我设置了会话变量,但我现在在那个页面而不是调用登录页面的原始页面。
如何显示弹出窗口,然后检查状态,然后如果登录则继续加载页面,如果没有,则再次弹出登录,如果没有登录错误消息,或者如果受保护的内容页面是,则重定向回主页链接到没有经过他的网站菜单。
我想对整个站点使用相同的login.php,它遍布服务器上的不同文件夹。
I am looking for a secure way to have a popup login window show up on the current page if a user clicks on a link to protected content.
I currrently have a login.php page with a form that is hidden and a javascript function that makes the form visible when it is called
then on the loading of the protected content page, I call this javascript function to show the login form.
On the form submit, the form calls a further php page called checklogin.php which has the mysql check and sets a session variable 'loggedin' if the user is found in the db.
The current problem is that on the checklogin page I set the session variable but I am now on that page and not the original page that called the login page.
How do I have the pop window show up and then check the status and then continue loading the page if logged in or throws the login pop up again with a login error message if not, or redirects back to the homepage if the protected content page is linked to without going throught he site menu.
I want to use the same login.php for the whole site which is spread around different folders on the server.
最满意答案
您可以在每个页面的php中嵌入登录算法,返回相同的页面但是如果需要登录则使用登录窗口,如果已经登录则返回内容。
You can embed in each page's php the login algorithm, returning the same page but with login window if login needed or content if already logged in.
更多推荐
login,页面,page,php,电脑培训,计算机培训,IT培训"/> <meta name="description
发布评论