L
L
LordPrimes2018-03-30 15:34:55
PHP
LordPrimes, 2018-03-30 15:34:55

How to fix the filter?

Hello, I wrote this code

$query = "SELECT * FROM products WHERE brand =  '".$_POST["category"]."' ";

   $brand = $_POST['category']; 
if (isset($brand)){
  
  $brandsdata =implode(",", $brand);
  $query .= " AND brand IN('$brandsdata')";

}
The essence of the problem is that $brandsdata does not matter made a vardump check
"SELECT * FROM products WHERE brand = 'Gigabyte' AND brand IN('')"
What is my mistake? The post is an array and the imploud should turn it into a string. But for some reason it does not.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Nikolaev, 2018-03-30
@gromdron

Replace with And more:
Read about SQL Injection

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question