This is my code
if ($row['username'] > 0) {
array_push($errors, "Username already exist");
die();
}
$passwordHash = password_hash($pass, PASSWORD_DEFAULT);
$sql = "INSERT INTO users (username, password, user_type) VALUES (:username, :password, :user_type)";
$stmt = $connect->prepare($sql);
$stmt->bindValue(':username', $username);
$stmt->bindValue(':password', $passwordHash);
$stmt->bindValue(':user_type', 'user');
$result = $stmt->execute();
if ($result) {
array_push($success, "Account Successfully Created!");
header('Location: /');
exit;
}
How do I echo the array_push($errors...
to the same page because it happens that after the form sent it is showing me white page but the same URL. Also, in array_push($success...
I want it to echo the message in the other page.