0

I'm trying to create a php website that users log into and they can submit data to a MySQL database. How do I make it so the users can only see data they've submitted and not everyone else's data? Should I use:

Echo $_sessions[user][piece of data] 

Am I on the right track or is there an easier way to go about this? Is there a template or tutorial that shows how this is accomplished? It seems all the demos on the web show you how to log in then stop after that point. I've been researching for a while and have not come across a way to implement this.

1 Answer 1

4

The solution is to have two tables in your database. The first table, "user", can have two columns, "user-id" and "name". The second table, "data", can then have two columns, "submitted-by" and "info".

Whenever a user submits some new data, you update the "data" table with the information and the user-id of the user. This way, when the user wants to read all the data they have submitted, you can simply limit the query to only return records with their user-id

1
  • Thanks for the response. What PHP function would you use to call up the data? Filter_var_array?
    – Kevin S
    Sep 22, 2015 at 9:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.