Ahe. Hello, I'm just looking for a login/password/register code that would be helpful for my site. <snipped URL> yes, its a role-play site and It'd be really helpful if people could LOGIN and then it would have a list of who's online. My members would have to register, etc. Then, when they are logged in it would have the member's username.

...Mmm. :)
Help me?

Dani AI

Generated

asked for a simple login/register system that shows each member's username when logged in and a "who's online" list. Below is a compact, practical plan plus small code examples (PHP/PDO + MySQL) and safety notes that address what was suggested earlier by and the package posted by .

A minimal data model and flow:

  • users table: id, username, email, password_hash, last_activity (DATETIME).
  • Registration: validate inputs, enforce unique username/email, hash passwords.
  • Login: verify hash, session_regenerate_id(true), store user_id and username in $_SESSION.

Example (hashing and verify):

$passwordHash = password_hash($password, PASSWORD_DEFAULT);
// store $passwordHash

// on login
if (password_verify($password, $row['password_hash'])) {
    session_regenerate_id(true);
    $_SESSION['user_id'] = $row['id'];
    $_SESSION['username'] = $row['username'];
}

Tracking "who's online":

  • Update last_activity for the logged-in user on each page request or via a heartbeat AJAX call.
  • Consider a short window (e.g., 5 minutes) to define "online".

Example queries:

UPDATE users SET last_activity = NOW() WHERE id = ?;

SELECT username FROM users
WHERE last_activity > DATE_SUB(NOW(), INTERVAL 5 MINUTE)
ORDER BY username;

Security and operational notes:

  • Use prepared statements (PDO) to prevent SQL injection.
  • Always run the site over HTTPS; set session cookies with Secure and HttpOnly.
  • Protect forms with CSRF tokens; limit login attempts and use email verification.
  • If taking code from contributors (like the download posted), audit it: check for plaintext passwords, eval/obfuscation, insecure session handling, and XSS/SQL issues before deployment.
  • Outsourcing (the option mentioned) is fine for speed; insist on readable source code, documentation, and ownership rights.

This gives a safe, maintainable baseline that fits a role-play site and can be extended with presence status, chat, or AJAX user lists.

Recommended Answers

All 2 Replies

The easiest way (and I hope this isn't against Daniweb policy) is to go to and pay someone to do it. They will make it to your specifications and it is usually pretty cheap.

Ahe. Hello, I'm just looking for a login/password/register code that would be helpful for my site. <snipped URL> yes, its a role-play site and It'd be really helpful if people could LOGIN and then it would have a list of who's online. My members would have to register, etc. Then, when they are logged in it would have the member's username.

...Mmm. :)
Help me?

Hi
I did something quick now hope you like it
i couldn't attach rar file so here is a link to download it from

Best of luck

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.