Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8658731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:50:23+00:00 2026-06-12T15:50:23+00:00

I have a profile.php page, and when someone views their own profile, it grabs

  • 0

I have a profile.php page, and when someone views their own profile, it grabs the id of their user and adds profile.php?UserID=* (* being the id number of a user). At the moment, there is no legit way to look at others profiles, but you are able to change the id in the url. Problem is, you can go to the profile of a user who doesn’t exist and make it will be the default profile page without anything on it. Is there a way to get the id from a page/url and see if it exists or not, and if not, to redirect to a certain page?

<?php
    include('./dbnotseen/global.php');
    $profile = mysql_query("SELECT * FROM admin WHERE username='$username'");
    $row = mysql_fetch_array($profile);
    $username = $row['username'];

    if (($session_username)) {

    }else {
        ("location: index.php");
    }

    //max per page
    $per_page = 1;

    //get start variable
    $start = $_GET['UserID'];

    //count records
    $record_count = mysql_num_rows(mysql_query("SELECT * FROM admin"));

    //count max pages
    $mac_pages = $record_count / $per_page;

    if (!$start)
        $start = 0;

    //display data
    $get = mysql_query("SELECT * FROM admin WHERE id='$start'");
    while ($row = mysql_fetch_array($get)) {
        $id = $row['username']; 
        $picture = $row['picture'];
        $admin = $row['admin'];
        $status = $row['status'];
        $desc = $row['description'];
        $twitter = $row['twitter'];
    }
?>

That’s the main part of the PHP in the profile.php. The rest is just getting a status, description etc.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T15:50:24+00:00Added an answer on June 12, 2026 at 3:50 pm

    You can check if the result set of your mysql query is not empty. Doing it with mysql_ functions would look like so:

    $get = mysql_query("SELECT * FROM admin WHERE id='$start'");
    if (mysql_num_rows($get) > 0) {
        while ($row = mysql_fetch_array($get)) {
            // rest of your code
        }
    }
    else {
        // redirect to another page
        header("Location: otherpage.php");
    }
    

    This would give you an idea on how you should approach it, but as @Madara Uchiha suggested in the comment to your question, you should stop using mysql_ functions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make clean url with htaccess I have a profile.php page
I have my user-based site set up as follows: Each user has their own
I have a web page with basicly the following URL structure: www.example.com/main.php?userId=mattias.wolff www.example.com/definitions.php?userId=mattias.wolff www.example.com/tasks.php?userId=mattias.wolff
So I have a profile page: profile.php?pin=xx , where I use the GET method
Do I have to put every file in a different folder? like: about-us/about-us.php profile/profile.php
i would like a simple help... i have a url like this: example.com/profile.php?id= &
Let's say you have a profile page that can only be accessed by the
I want that every user has a profile-url like this: www.example.com/username But my php
I have a link http://mysite.com/myname which shows the profile page.. But if i use
I am working on a comment voting system. I have a page profile_new.php?id=194 That

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.