I'm working on an application that needs some data to be sent to db through a form. I've developed an input test class for having a clean input. This is my code:
class test
{
public static function inputTest($inputPar)
{
$con=mysqli_connect("localhost","****","*****","*******");
// Check connection
if (mysqli_connect_errno()) {
return "Failed to connect to MySQL: " . mysqli_connect_error();
}
$text=htmlspecialchars($inputPar);
$text0=trim($text);
$text1=stripcslashes($text0);
$text2= strip_tags($text1);
$text3 = str_replace("’","'", $text2);
$text4=mysql_real_escape_string($text3);
mysqli_close($con);
return $text4;
}
}
When I try to use it everything works except the last $text4=mysql_real_escape_string($text3);
that just sends me back an empty string every time.
I just converted all the application to the new PDO driver (don't mind about the mysqli driver in this class, it is just a quick example to make it work), and I read that some control is now unnecessary. So I'm asking which control is still mandatory for having a good level of security.
The Php version is 5.5.9.