Is there any security threat here?
$con = mysqli_connect("***", "***", "***", "***");
mysqli_query($con, "set names 'utf8'");
$id = $_GET["id"];
$result = mysqli_query($con,"SELECT * FROM document_$id");
while($row = mysqli_fetch_array($result)) {// echo table }
I am curious about my use of the $_GET
variable, since that can be altered by a user. If there is a danger here, could something like this work?
If $_GET['id']
is not an integer -> redirect to error page
0; DROP TABLE Students
? Solution is never try to imagine how to clean your inputs (even if in this case it may work) but always to use query parameters, without exceptions. It has to be a rule otherwise your code will fail (someday) in a way you didn't expect or in a place you didn't consider or just simply because you forgot it. \$\endgroup\$