I downloaded the wysiwyg plugin there added img and other html codes, but the problem is that hackers can also enter some sql queries how to fix it?
The problem is that if I turn on the conversion to html characters, then the html codes do not work, and if I don’t insert a conversion, hackers can do something ..
here's the news feed code:
<? include "bd.php"; $id = $_POST['id']; $result = mysqli_query($db, "SELECT * FROM users WHERE id='$id'"); $myrow = mysqli_fetch_array($result); $post = $_POST['post']; if($_POST){ $date = date("dmY H:i"); $result2 = mysqli_query ($db, "INSERT INTO wall_post (user_id,date,post) VALUES('$id','$date','$post')") or exit(mysqli_error($db)); if ($result2){ echo "<html><head><meta http-equiv='Refresh' content='0; URL=page?id=$id'></head></html>"; } } else{ echo "<html><head><meta http-equiv='Refresh' content='0; URL=fail_try?id=8'></head></html>"; } ?> and here is the output code:
<? session_start(); include "bd.php"; $id = $_GET['id']; $result = mysqli_query($db, "SELECT * FROM wall_post WHERE user_id='$id' ORDER BY id DESC"); $result2 = mysqli_query($db, "SELECT * FROM users WHERE id='$id'"); $myrow2 = mysqli_fetch_array($result2); while ($row = mysqli_fetch_array($result)){ $post_id = $row['id']; $md5_id = md5(md5(md5(md5($id)))); echo " <div class='profile_post'> <p> <a href='page?id=$id'><img class='avatar' src='$myrow2[avatar]' align='left'></a> <a href='page?id=$id' class='page_href'>$myrow2[lastname] $myrow2[firstname]</a><br> <font color='gray' size='2'>$row[date]</font> <div class='delete_news'><a href='delete_post?post_id=$post_id&hash=$md5_id&id=$id'></a></div> </p> <p>$row[post]</p> </div> "; } ?>