How to Stop Inappropriate Contents to Insert in Database (PHP)


Hi,

Created a website for my client https://www.jeenmount.com/ and client need to see what people searching for on his site. So we are inserting each search in database or increase number of search if Key already exist there.

My issue is inappropriate search like below
SEMrush

“>alert(String.fromCharCode(88,83,83))
place for destination wedding’A=0
pink city mall in jaipur” or (1,2)=(select*from(se
pink city mall in jaipur99999′ union select unhex(
heritage wedding resort hotel jaipur” and “x”=”y
heritage wedding resort hotel jaipur and 1>1

I think this types of search are doing by Bots or any other things.

What i am looking for is …… If search queries are with these types of strings or inappropriate characters then either clear code and adjust in proper format or avoid to insert in database.

Please help us that how can we do that.

Using already “mysql_real_escape_string” “htmlspecialchars” for security but unable to stop inappropriate contents to insert in database.

Hope for quick response.