i'm having trouble with security for a website. I've been using php with PDO. So what i want to avoid is if a user inputs code into message box that executes when it is sent. So for example purposes if the user enters the following <?php echo "123"; ?>
into my current message box, it'll send a blank box to the recipient. My code is the following;
$insert = $pdo->prepare("INSERT INTO message (sender_id,recipient_id,subject,message,reference_id) VALUES(:userID,:recipientID,:subject,:msg,:ref)");
$insert->bindParam(':userID', $user['user_id'], PDO::PARAM_INT);
$insert->bindParam(':recipientID', $recipientId['user_id'], PDO::PARAM_INT);
$insert->bindParam(':subject', $subject, PDO::PARAM_STR);
$insert->bindParam(':msg', $msg, PDO::PARAM_STR);
$insert->bindParam(':ref', $newRef, PDO::PARAM_INT);
$insert->execute();
I pretty much want anything a user enters into the message box to be converted into a string before POST-ing to the database. So in this case the recipient would receive the message <?php echo "123"; ?>
instead of a blank box. Note, i was under the impression that i already sanitize the user input during the variable binding ($insert->bindParam) and that this was sufficient enough that people could not enter code in the message box. But i am told that they can and have drop tables successfully for example in my database as a test.