I would like to understand this little code. Which I see, avoid SQL-Injection
They could correct me and add information. Sorry if I mention failures
<?php
$mysqli = new mysqli("localhost", "root", "", "bdpersona");
$sql = $mysqli->prepare("insert into tbcontactos (nombre, edad, direccion, descuento, descripcion, cantidad) values (?, ?, ?, ?,? ,?) ");
$sql->bind_param("sisisi", $nom, $edad, $dir, $des, $desc, $cant);
$nom = $_GET['nombre'];
$edad = $_GET['edad'];
$dir = $_GET['direccion'];
$des = $_GET['descuento'];
$desc = $_GET['descripcion'];
$cant = $_GET['cantidad'];
$sql->execute();
?>
$ mysqli = new mysqli ("localhost", "root", "", "bdpersona");
-I connect to my computer, which is the server where the database is located. -The profile of who access is 'root'
-Do not have a password to access the profile
-The database is called bdpersona
$ sql = $ mysqli-> prepare ("insert into tbcontacts (name, age, address, discount, description, quantity) values (?,?,?,?,?,?)");
This part I do not understand well
-I'm going to prepare? to put in the fields of name, age ... of the table tbcontacts some values that "are secret" with the symbol ?
$ sql- > bind_param ("sisisi", $ nom, $ age, $ dir, $ des, $ desc, $ cant);
I also do not understand this part
I link with the values that I receive from a form and I put them in order in the previous table of prepare and I also indicate that s is string and i is int.
Could you add information or corroborate that I understand the code well? In this code where SQL-Injection is avoided?
Thank you very much.