PHP验证脚本 [英] PHP Authentication Script
问题描述
我发现什么看起来像一个良好,安全的PHP登录脚本,但我有麻烦搞清楚如何实现它。 (它座落在这里 http://www.adesdesign.net/php/tutorials/ PHP / php_login1.php )
I have found what looks like a good, secure PHP login script, however i am having trouble figuring out how to implement it. (It is located here http://www.adesdesign.net/php/tutorials/php/php_login1.php)
我是新来的PHP所以不知道多少呢。我无法弄清楚如何真正验证用户身份,并返回一个消息给他们,如果失败,在哪里粘在整个提到的所有函数和类。
I am new to PHP so don't know much yet. I can't figure out how you actually authenticate a user and return a message to them if it fails and where to stick all the functions and classes mentioned throughout.
我知道这可能是一些非常明显的,但我只是不明白这一点!
I know it may be very obvious to some but i just don't get it!
感谢。
推荐答案
不是最简单的脚本/方式做到这一点,但相当完整。你说你是新来的PHP,那OOP?
海事组织,这一次似乎更容易: tutoriel
Not the easiest script/way to do it, but quite complete. You say you're new to php, what about OOP ? IMO, this one seems easier : tutoriel.
原理始终保持不变:您在数据库中有一个表用户。
Principle always stays the same : you have in your database a table with your user.
访问者来尝试登录。
如果他的登录/密码都不错,您重定向他到自己的PROFIL /任何你想要的页面,你在 $ _存储SESSION ['verifiedUser'] =真
,
如果他的登录/密码是错误的,他重定向到登录页面,并显示错误消息。
The visitor come and try to log.
If his login/password are good, you redirect him to his profil/any page you want and you store in $_SESSION['verifiedUser'] = true
,
if his login/pass are wrong, he's redirected to the login page, with an error message.
和在限制为用户登录的每一页,添加
And in every page restricted to logged user, you add
if (!isset[$_SESSION['verifiedUser']) )
header('Location:loggingForm.php');
这篇关于PHP验证脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!