Good day phphelp.com
I am new to MySQL and have been studying basic commands and gathering information regarding SQL injections.
I showed some code that inserts data into table using PHP and MySQL to the programmer in my workplace and the programmer told me that this code
[php]//record data into table
$sql=‘INSERT INTO sample(fname,lname,age,email,gender,os,checked_data,comment) VALUES ("’.$fname.’","’.lname.’","’.age.’","’.email.’","’.$gender.’","’.$os.’","’.$checked_data.’","’.$comment.’")’;
$stmt=$dbh->prepare($sql);
$stmt->execute();[/php]
is vulnerable to SQL injection.
Question is
・what are the minimun things I could do to prevent SQL injections?
・what do I need to know?
・from the above codes what are the things I need to rewrite to prevent SQL injections?
I will provide whole code if necessary thanks!