MySQL query based on user input

 
To save from SQL injection attack, use:

1. $search_query = mysql_real_escape_string($_POST['blahblah']);

$query  = "SELECT name, age FROM people WHERE uid = '".$search_query."' LIMIT 0 , 1";
 
2. $search_query = mysqli_real_escape_string($_POST['code']);
 $sql = "select * from user where code='$search_query'"; 

Comments

Popular posts from this blog

Real-Time Web Interface to MQTT using Socket.io and Node.js

Insert session variable into MySQL database

Insert CheckBox and Radio button Data in MySQL Database Using PHP