Here's my code:
if(isset($_POST['doSEARCH'])){
$mysqli->query("SELECT * FROM data WHERE title = '$search'");
}
?>
<form action="" method="post">
<input type="text" name="search" />
<input type="submit" value="SAVE" name="doSEARCH" id="doSEARCH" />
</form>
1 Q: can I use this method without using mysqli_real_escape_string
? Is it safe?
$search = filter_input(INPUT_POST, 'search', FILTER_SANITIZE_SPECIAL_CHARS);
if(preg_match("/[^a-z0-9 ,.]/i",$search)){
header('Location: 500error.html');
exit();
}
2 Q: any other short solutins for this? (without using mysqli_real_escape_string
)
thank you!