Before we talk about how to prevent SQL injection, we have to know the impact of SQL Injection attack which is one of the most dangerous attacks on the web.
The attacker can steal your data or even worse, the whole web server can be stolen from one SQL injection vulnerability.
I wrote this post to show you how to prevent SQL injection.
If you need to know more about SQL injection itself and its types and all other stuff, you can do a simple search on google if you want.
The solution is to clean the request parameters coming from the user.
Thanks in advance.