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.

closed as too broad by Andy Hunt, Ixrec, user40980, gnat, durron597 Sep 22 '15 at 13:52

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

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

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

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