So I have a form and need to validate it. So what I'm doing is
if(empty($name) || empty($username) || empty($email) || empty($password)){
$_SESSION['comp_form'] = "Complete all fields";
header('Location: register.php');
}
if(strlen($password) < 5){
$_SESSION['pass_leng'] = "Choose a longer password";
header('Location: register.php');
}
I'm doing this because I need to display the Session on another page, but only one error gets shown. What I'm trying to do is something like this where all errors are shown at once.

Am I on the right track? Or is there another way to go about this. Because I can only display one message at a time using
$_SESSION['comp_form'] = "Complete all fields";
header('Location: register.php');
exit()