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 7177893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:48:32+00:00 2026-05-28T16:48:32+00:00

On my website I have a user login system, when they login they are

  • 0

On my website I have a user login system, when they login they are taken to their profile page, which is deism ate by their uid. The thing is, there was nothing to stop a user just changing the uid and going to someone else’s profile and Acting as them. To stop this I implemented a URL/MySQL system by which if the uid of the user is not the uid in the URL, they are redirected to their own profile. The problem here is that on the profile there are forms which change the URL, in doing so removing the uid query, resulting in the page (because the uid is missing) taking you to your profile and ignoring the form input.

The code is:

<?php
mysql_connect ('x', 'x', 'x');
mysql_select_db ('x');

if(isset($_COOKIE['wd_un'])) {
    $un = $_COOKIE['wd_un'];
    $pass = $_COOKIE['wd_pass'];

    $cook = "SELECT * FROM x WHERE username = '$un' AND password = '$pass' limit 1";
    $cookr = mysql_query($cook) or die (mysql_error());
        if(mysql_num_rows($cookr) == 0) {
            header ("Location: index.php");
        }
        else {
            $urluid = mysql_real_escape_string($_GET['uid']);
            $uidcheck = "SELECT * FROM x WHERE username = '$un' AND password = '$pass'";
            $uidcheckq = mysql_query($uidcheck) or die (mysql_error());
            while($rcu = mysql_fetch_assoc($uidcheckq)) {
                $dbuid = $rcu['uid'];
                        if($urluid != $dbuid) {
                            header ("location: home.php?uid=$dbuid");
                        }
                        else {
                        }
            }
        }
    }
mysql_close();
?>

Is there a work around?

  • 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-05-28T16:48:33+00:00Added an answer on May 28, 2026 at 4:48 pm

    This code block you have here is riddled with badness.

    First, you should absolutely never store a user’s password in a cookie.
    You SHOULD store only a session ID in the cookie, then store the rest of the session data in a session table in your DB that contains the user’s id and any other things that you may want to have basic access to… password should not be in this table either.

    Now, you can use the user_id in the URL safely cause the cross reference will keep people out.

    on load of course you cross reference the mysql result from your session table that was pulled based on your cookie id. Obviously boot them if they don’t match.

    As for your form redirecting, you need to restructure how you handle posting then. You can make your profile page always pull only the profile related to the session id in your cookie. That would remove the dependency on URL and solve this problem completely.

    Also – Please look into mysql_real_escape_string() to sanitize your inputs. It is incredibly dangerous to blindly accept cookie info for a mysql query. Unless you really do aim to leave huge injection holes in your site.

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

Sidebar

Related Questions

I have been comissioned to make a website complete with a user login system
I already have an advanced user login/register system on my website ( colemansystems.psm2.co.uk ).
I have a classifieds website which I am creating a login system for... In
So, I have a user driven website. Users can post whatever they want, even
I have a website where a user chooses a template of their choice for
I have a website and when the user logs in they can click on
I have a website which sells a product to the user (downloadable). I am
I have a website, which will be frequently updated. Sometimes changes happen to User
I have a website, with a user system. I want to integrate wordpress's user
I have a login system in place for my website, the details of the

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.