I have a comments page on my site and I was wondering if it is vulnerable to some sort of sql attack or something else. At the moment users can type what they want, they can even write a php script and it will upload to the database. Is this a problem and how can I fix it.
This is the script I use:
$name= $_POST['name'];
$email= $_POST['e_mailaddress'];
if(isset($_POST['comments']) AND $_POST['comments']!=''){
$comments= $_POST['comments'];
$comments_sent = 'true';
$dbcn = new connection();
$sql= "INSERT INTO contact (name, email, comments) VALUES (:name, :email, :comments);";
$query = $dbcn->dbconnect()->prepare($sql);
$results = $query->execute(array(
":name"=> $name,
":email"=> $email,
":comments"=> $comments
));
}