Not inserted into the table

Hi, help: I ​​have created my database and a table but the data is not inserted into the table … the connection with the database is successful but the data is not inserted:

<php
$nombre = $_POST["nombre"]; 
$email = $_POST["email"];

$sql = "INSERT INTO otras (nombre, email) VALUES ('$nombre', '$email')";

if (mysqli_query($conn, $sql)) {
  
  echo "exito"; 
 
} else {
  echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
mysqli_close($conn);
    }
?>

The first suggestion I want to give you is to either use parameterized queries or sanitize/validate your input. Right now, you’re just dumping unchecked POST data into the query string, which leaves your site wide open to SQL Injection Attacks. See also the warning in the official docs: PHP: mysqli::query - Manual

As for the issue itself, do you have a URL where we can see this?

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.