Hey now i have this but when i register only the index.php page shows up. Without the success message. When the registry is completed i redirected to index.php?msg=1 so that's in my opinion correct?
<?php
if (isset($_GET['msg'] == 1)) {
echo "You have successfully registered.";
}
require_once('connect.php');
$errors = array();
if (isset($_POST['submit'])) {
if(empty($_POST['username'])){ array_push($errors, 'You did not submit a username'); }
$old_usn = mysqli_query($connect, "SELECT id FROM users WHERE name = '".htmlentities($_POST['username'], ENT_QUOTES)."' LIMIT 1;") or die(mysqli_error());
if (mysqli_num_rows($old_usn) > 0) { array_push($errors, 'This username is already registered.'); }
if (sizeof($errors) == 0) {
$username = htmlentities($_POST['username'], ENT_QUOTES);
$email = htmlentities($_POST['email'], ENT_QUOTES);
mysqli_query($connect, "INSERT INTO users (name, hashed_pw, email, joined)
VALUES ('{$username}', '{$password1}', '{$email}', NOW());") or die ($connection_error);
header('Location: index.php?msg=1');
}
}
?>