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

  • SEARCH
  • Home
  • 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 8761509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:18:12+00:00 2026-06-13T15:18:12+00:00

A user can submit his data, after login. There is two tables in mysql:

  • 0

A user can submit his data, after login. There is two tables in mysql: items, categories. Categories has a field: user_id, but in item table, there isn’t, every item should belongs to a category.

When a user submitting a category, its fine, i get the user id from session, and inserting it.
When he submits an item, i set the category_id for it.

The problem is, the user can simply rewrite the category_id (javascript, on the frontend, click on a category : set the category_id), and submit the item into a category which is not related to him.

Two solutions what i’m thinking (but i haven’t made like this):

When the user inserts an item, i check the category relation, and if it’s not the user’s one, its exit.

Add the user_id field into the items table too (not looking as a good option).

What is the good way or what’s the proper/common solution in this case?

  • 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-06-13T15:18:13+00:00Added an answer on June 13, 2026 at 3:18 pm

    Add the user_id field into the items table too

    If you already have the user_id in the categories table, and you’re certain that each item has a category, then this is unnecessary duplication, as you suspect.

    Check the category relation, and if it’s not the user’s one, its exit.

    That’s the way to do it – when you read the category id before inserting an item, make sure that category belongs to the user. Simple. I would probably just show_404(), but it’s up to you if you want to show a meaningful error message.

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

Sidebar

Related Questions

I recently made a simple game where user can submit his/her high scores online.
I want a settings page where the user can submit his hometown/biography/email settings and
I currently have a wysiwyg iframe where the user can submit input to another
I have form where user submits field. Field can have letters, numbers, and punctuation.
A user can import data into our website from a file. The data normally
In my application user can add there reminder for the specific day and reminder
On my site, the user can watch his profile. In his profile he can
I have a form where the user can update his name and last name.
I have a template where the user can input data about himself, and upload
I want to create user profile with image. That user can upload his photo,

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.