Well here with a doubt, I currently have querys where I ask for information and at the end a clause WHERE
where I ask for that information about the id of the current session, that is only the active user at that moment, and I want to adopt a Query prepared because having the variable $_SESSION
makes me too vulnerable to sql injections.
This is what I currently have:
if(isset($_GET['id_user'])){
sql "SELECT nombre, apellidos, edad FROM users WHERE id = '".$_GET['id_user']'";
}
What I want is this:
sql = "SELECT nombre, apellidos, edad FROM users WHERE id = ?";
$id = $_POST['id'];
$stmt=$mysqli->prepare($sql);
if ($stmt) {
$stmt->bind_param("i", $id);
$stmt->execute();
$Resultado = get_result($stmt);
while ($row = array_shift($Resultado)) {
}
}
But I do not understand how the query will only take the user id of the current session:
Would you understand that this id =? in this line you specify that you only select the data of that user in specific?
I hope and someone can help me with this problem
Thank you all.