suppose i have a query like this :
$std_id = $_POST['std_id'];
$name = $_POST['name'];
$family = $_POST['family'];
$sql = "insert into student set
std_id = $std_id,
name = '$name',
family = '$family'";
$query = mysql_query($sql,$conn);
i read in a php security book that if user enter a value for family field like :
ahmad';drop database test#
can delete database test;
but we know that the mysql_query() function only allow to execute one query .
i want to know how can this input to be unsafe
Answer
There are many delusions in your question.
Let's sort them out.
- mysql_query() doesn't support multiple queries execution.
(so, it is useless to delete anything) - dropping tables in the separate query is not the only way of the SQL injection.
(so, it is useless to delete anything again) - To protect your query you have to follow some well-known techniques, not some handmade inventions of doubtful efficiency.
No comments:
Post a Comment