i am using this code
<?php
include('connection.php');
$heading = $_POST['upd_head'];
$note = $_POST['upd_text'];
$post_id = $_POST['up_post_id'];
$supd_head= "UPDATE posts SET heading= ?, note=? WHERE post_id=?";
$stmt_head= mysqli_stmt_init($db_conx);
if(!mysqli_stmt_prepare($stmt_head, $supd_head)){
echo "sql is not ready";
}
else{
mysqli_stmt_bind_param($stmt_head, "sss", $heading,$note,$post_id);
mysqli_stmt_execute($stmt_head);
}
?>
when i give this input
<script>alert('hack');</script>
it saves as it is in the database and gives an alert message when i refresh page after updating data. Why its not sanitizing the data first? But i think there is no use of mysqli_real_escape_string
when using prepare statement.