how to prevent sql injection php code example
Example 1: How can I prevent SQL injection in PHP?
$unsafe_variable = $_POST["user-input"];
$safe_variable = mysql_real_escape_string($unsafe_variable);
mysql_query("INSERT INTO table (column) VALUES ('" . $safe_variable . "')");
Example 2: how to stop bank entry in php mysql server database
if($name!="" && $email!=""){
$sql="insert into info(name,email)values('".$name."','".$email."')";
$query=mysqli_query($conn,$sql);
}else{
echo "All field are required";
}