0

I want my websites allow users to use pulldown menu to filter through a list of data provided by MySQL. The choices from the pulldown menu is used in the following way:

$pulldown_choice = _GET['pulldown_choice'];
..... #other codes here
$sql = "SELECT * FROM tablename WHERE item LIKE '%$pulldown_choice%';

My question is: do I need to worry about database injection from the pre-defined, pulldown list choices? Thanks!

LearnAWK
  • 549
  • 6
  • 17

1 Answers1

1

Someone might tinker around with the request and manually invoke the URL with ...?pulldown_choice=WHATEVER_YOU_WANT (e.g. *).

I probably would only pass an index and have the options on your server side fixed.

user2084865
  • 625
  • 1
  • 7
  • 18
  • I do this all the time. It is far from uncommon but the average programmer never thinks about it imo – Drew Jul 19 '15 at 02:39
  • Your comments are eye openers for me. I will definitely read more about this topic. – LearnAWK Jul 19 '15 at 03:58