开发者

How to create a simple log in system to show/hide content and allow chatting with other users

开发者 https://www.devze.com 2023-02-06 01:59 出处:网络
another web programming question. This time, I\'m looking to create a simple log in system that will allow a u开发者_运维问答ser to log in and register. When they do, they see a special page not viewa

another web programming question. This time, I'm looking to create a simple log in system that will allow a u开发者_运维问答ser to log in and register. When they do, they see a special page not viewable to users not logged in. No account options or anything, just log in or log out. If anyone has any advice on how to do this, it would be greatly appreciated!


Any advice? The best advice is probably to use one of the few thousand existing scripts for that.

The general approach would be:

  • Make a registration page. On POST save username and hashed password (serialize into file or database).
  • Make a login form. On submit look up entry in user database/file, compare against hashed password. If it matches, set $_SESSION["user"]=.. to valid value.
  • On "special" page, start session, check for valid user value, otherwise die("with error message.")
  • Since your title asks for a chat system along, well that's as simple. Make a form. Allow submitting of messages from one user, use a dropdown to let people select the recpient, save received values into database. Give every user a message inbox page, and display the stored messages there.
0

精彩评论

暂无评论...
验证码 换一张
取 消