I am writing a website and I have this code that normally should insert just one entry but in my case is duplicating the entries.
require_once 'login.php';
$conn = new mysqli($hn, $un, $pw, $db);
if ($conn->connect_error) die("Fatal Error");
$query = "INSERT INTO cats(family, name, age) VALUES('Caracal', 'Panou', 4)";
$result = $conn->query($query);
if (!$result) {
die("Database access failed");
}
Here is the code of login.php
<?php
$hn = 'localhost';
$db = 'publications';
$un = 'sandro';
$pw = 'mypasswd';
?>
I don't use a form. I run the script just by refreshing the page.
Can somebody help to understand what is going on?
Thank you