I know that a function mysqli_real_escape_stringcan be used to prevent SQL injection. (However, mysql_real_escape_string () will not protect you from some injection)
My question is when should the mysqli_real_escape_string () function be used?
Situation 01
I have a registration form with 4 fields called First Name, Last Name, Email, Password.
Should I use mysqli_real_escape_string () to insert a query? All four fields?
Or is it enough to use in the login form?
Situation 02
Do I have a profile page like profile.php? user_name = damith
I used $ _ GET ['user_name'] in many functions on this page.
Should I use mysqli_real_escape_string () in all of these functions?
source
share