Jump to content

Recommended Posts

ok, im going to have an array to show how many "technologies" a user has unlocked.

 

 

$user['tech']

 

^^ that would mean the user has no technologies

 

 

 

 

$user['tech'][1] = 1

$user['tech'][2] = 1

$user['tech'][4] = 1

 

^^ that would mean tech's 1,2 and 4 are unlocked

 

How the data is stored is db for the example above is like this:

 

[user_id][tech_id]

1            1

1            2

1            4

 

To set the variable $user['tech'], i just do a querry/array of all the rows in the db where there is your user_id

 

Then I do a for_each for the database result and it will set $user['tech'][THE TECH ID] = 1

 

However, couldn't someone just go to "mysite.com/index.php?user['tech']['8'] = 1" and suddenly have tech 8?

 

How do I avoid this? Can I delete an array before playing with it? Is there a smarter way to get this data?

Link to comment
https://forums.phpfreaks.com/topic/64962-array-security-question/
Share on other sites

No, but you see, it doesn't set EACH variable. If you dont have ID 8 in your database (as purchased), then it woudl leave it blank. Example:

 

$user['tech'][6] = 1

$user['tech'][7] = 1

$user['tech'][9] = 1

 

8 Isn't set, so it ins't purchased. Then someone could just put "user['tech'][8]=1" in the URL and have it.

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.