I\'am attempting to build a register page and the current code runs correctly but I\'am getting duplicate inserts on the DB side. I\'ve researched and have tried several dif
If the page is refreshed, or someone hits it again using the "back" button, the data will get resent to the server and thus get inserted twice. You need to redirect the user to another page, or the same page, using the POST/REDIRECT/GET pattern to avoid this. Sending a 303 HTTP response will tell the browser to replace that page in its history and avoid re-sending the posted data.
if (mysqli_query($connection, $register)) {
header('Location: index.php', true, 303);
exit;
}