i am trying to do this for past days , i tried many functions such as
strip_tags , mysqli_real_escape_string , ..etc
// Prevent MySQL Injection Attacks
function cleanQuery($connector,$string){
if(get_magic_quotes_gpc()) // prevents duplicate backslashes
$string = stripslashes($string);
return mysqli_escape_string($connector,$string);
}
but none gave me the result i want .
what i want is to enter an article text , allow html editing but prevent from mysqli injection ... can anyone helpout ?
as an example : i have this :
$data = $_POST['data'];
echo "<form method='POST' action='index.php?do=check'>
<textarea rows='10' name='data' cols='50'>$data</textarea>
<input type='submit' value='send' name='B1'>
</form>
";
mysqli_query($conn,"insert into table(field)values('$data')");
value of data is :
<p align="center"><b><font size="6">test</font></b></p>
<table border='1' width='100%'>
<tr>
<td> what's your name ?</td>
<td> my name is `Jhone`</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
an html input
so how can i insert that into database with no issues ?