Let's say I have a website which sells instruments. I am using PHP and MySQL in order to dynamically build the products page labelled products.php
.
Now my table has multiple columns, such as ParentCategory
and the like. Pressing on the products
tab would take you to category.php
, where there will be some categorical buttons you can press on, which will take you to products.php
and only show you the relevant products.
Now here enlies the problem. To retrieve the items from the database, we need to set a query like
SELECT * FROM productlist WHERE ParentCategory=1
From the category page, the buttons are wrapped in a form, and each button submits a variable called query
using POST
. The value would be something like ParentCategory=1
.
The full SQL query, with the tablename, is hidden, however the multiple subqueries that the buttons have to submit, such as ParentCategory=1
or ParentCategory=2
are displayed in the HTML of the page itself.
What I want to know is, is this a massive security flaw? As in, could a malicious user exploit such information for hacking purposes? Personally I couldn't think of a way a user could exploit the site after only knowing its column names, but I'm also only starting out in web development.
If that's the case, then what's the safest or universal way that these queries are passed? I would have thought GET
but that lengthens the URL and opens the problem of injection up, since any values can be passed.