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

  • SEARCH
  • Home
  • 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 8961711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:57:27+00:00 2026-06-15T15:57:27+00:00

My Profile php <?php //profile.php require_once ‘includes/global.php’; //check to see if they’re logged in

  • 0

My Profile php

<?php
//profile.php

require_once 'includes/global.php';

//check to see if they're logged in
if(!isset($_SESSION['logged_in'])) {
    header("Location: login.php");
}

// finding user and viewing it
$tools = new FindUser();
$user = $tools->get($_REQUEST['userID']);

?>

This is my php for viewing user profile.

http://mywebsite.com/profile.php?userID=5 its working fine in this way.

i want my code to check if user is available in database for example if i add ?userID=10 which is not present in database it gives out mysql error or even if i use http://mywebsite.com/profile.phpthen also it give error.

so now i want if user is not available in database it should give that user is not available and when we use simple http://mywebsite.com/profile.php it should give auto add it to userID=1 OR REDIRECT it to home.php

If there is other way of doing this please let me know. well im very newbie in this field

Thanks for looking my question and answering 🙂

Solved

<?php
//profile.php

require_once 'includes/global.php';

//check to see if they're logged in
if(!isset($_SESSION['logged_in'])) {
    header("Location: login.php");
}

$UserID = $_GET['userID'];
$CheckQuery = mysql_query("SELECT * FROM users WHERE id='$UserID'");

$CheckNumber = mysql_num_rows($CheckQuery);
if ($CheckNumber !== 1)
{
    header("Location: index.php");
}

// finding user and viewing it
$tools = new FindUser();
$user = $tools->get($_REQUEST['userID']);

?>
  • 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-15T15:57:29+00:00Added an answer on June 15, 2026 at 3:57 pm

    You shouldn’t use MySQL As it’s depreciated,

    If you really wish to use MySQL You could check at the start of the script if there is a row count for the User ID, Example:

    <?
        $UserID = $_GET['UserID'];
        $UserID = mysql_real_escape_string($UserID);
        $CheckQuery = mysql_query("SELECT * FROM users WHERE userID='$UserID'");
    
        $CheckNumber = mysql_num_rows($CheckQuery);
        if ($CheckNumber !== 1)
        {
    
        // Do something If user is Not Found
        // Redirect to Another Page OR Something
        }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

my code for the php page displaying the divs <?php session_start(); require_once(classlib/mainspace.php); if (isset($_SESSION['username'])==FALSE)
<?php require 'db.php'; include_once(header.php); include_once(functions.php); include_once(profile.php); if(isset($_POST['search_term'])){ $search_term = mysql_real_escape_string(htmlentities ($_POST['search_term'])); if(!empty($search_term)){ $search =
I'm making an profile page in PHP, How to make an url like domain.com/profile.php?user=admin
I need help rewriting online.php to -> /users/online and profile.php?id=3426 to -> /users/3426 and
I am trying to make clean url with htaccess I have a profile.php page
i would like a simple help... i have a url like this: example.com/profile.php?id= &
On my site, user profiles can be reached by the url www.example.com/user/profile.php?uid=3 I want
Do I have to put every file in a different folder? like: about-us/about-us.php profile/profile.php
i'm new to mod_rewrite, and i'm trying to convert my web address from: website.com/profile.php?user=andy
now I can make it work with user-profile.tpl.php page,all this page does is to

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.