Jump to content

Recommended Posts

Hi,

 

I am quite new to php and need to secure my site as it will hold personal info.

 

For example, when a user selects:

<a href="EditTenantFormT.php?UID=<?php echo ($row['UID']) ?>">Edit My Details</a>

 

It passes them to a page to edit their data. However, as the 'user id' is passed through the URL this is not secure as the db can be queried through the URL:

http://localhost/OceanBlue/EditTenantFormT.php?UID=20

 

What would be the best (and easiest) method of stopping the UID being shown in the URL. I did try urlencode/urldecode but it didnt seem to work - is this the best method?

Link to comment
https://forums.phpfreaks.com/topic/97615-need-advice-on-url-security/
Share on other sites

to explain on papaface post (which i recommend),

personally i store the userid in a session ie $_SESSION['UserID'],

then have a routine to check the access level (if that level allows me to edit others records then i accept the get "UserID=xxx" from the URL if not i ignore it.. and set theID back to the UserID

 

ie

<?php
start_session();
$isAdmin = checkaccess($_SESSION['UserID']);

if (isset($_GET['UID']) && ($isAdmin === true))
{
$uID = $_GET['UID'];
}else{
$uID = $_SESSION['UserID'];
}

//Load records with $uID as the userID

function checkaccess($userID)
{
//search user ID in mySQL and get UserLevel
if ($userlevel == 1)//whatever is the Admin Level
{
return true;
}else{ 
return false;
}
}

?>

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.