Hi, i have already made a user registration page and log in pages but i need to know how i can make it possible for other people to view profiles from other users on my site.

Dani AI

Generated

Good start, — and useful pointers from and . They pointed you toward a single dynamic profile endpoint; below are practical, production-minded steps to turn that into a safe, maintainable feature without repeating the exact examples already posted.

Keep the data model simple and indexed: an integer primary key, a unique username/slug (indexed), display name, bio, avatar filename, visibility flag, and timestamps. Use a prepared query to fetch a single row and always escape output to prevent XSS. Example (assumes a PDO connection and a validated identifier variable):

$id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
if ($id) {
    $stmt = $pdo->prepare(
      'SELECT username, display_name, bio, avatar_path, visibility FROM users WHERE id = :id LIMIT 1'
    );
    $stmt->execute([':id' => $id]);
    $user = $stmt->fetch(PDO::FETCH_ASSOC);
    if ($user) {
        echo htmlspecialchars($user['display_name'], ENT_QUOTES, 'UTF-8');
        // safe output, then render other allowed fields
    } else {
        http_response_code(404);
        echo 'User not found';
    }
}

Security and UX notes: do not rely on ad-hoc hashes to stop SQL injection — use parameterized queries and input validation instead. Treat profile fields differently: sanitize plain text with htmlspecialchars; if you allow limited HTML (for bio), sanitize with a library that whitelists tags. Handle avatar uploads outside the webroot or rename files, check MIME type, resize images, and serve with correct headers. Add a visibility column so users can choose public/members-only/private and enforce checks before rendering.

Operational tips: add UNIQUE(username) and proper indexes for fast lookups; return 404 for missing users and 403 for access denied; expose canonical URLs (store a slug) for SEO; keep server logs for failed lookups when debugging. These additions will make the basic idea suggested by and robust and ready for real use.

Recommended Answers

All 3 Replies

Member Avatar for Member #120589

Create a profile.php page.

If you've got user hyperlinks - they should have the user's id as part of the querystring. This is then processed from the $_GET variable and data is taken from the DB and displayed.

A hashed "confirm" parameter may be useful to prevent users from messing with the querystring.

Simple.

what ardav's trying to tell you is that you can have a page that will display users on your site with there picture displayed.the link on the picture can be something like

yourdomain.com/profile.php?userid=12456

where the userid will be the id of the person in your database
and once this is clicked there profile will be shown via get using

$_GET['userid'];

and via a sql statement you generate the user using the userid. hope that helps and don't orget the hashing he talked about so as to prevent sql injection. shalom shalom

Thanks guys i appreciate your help.

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.