I'm trying after submitting a form, redirect from registration.php to index.php and show message there. Structure is like this:
registration.php
class Registration
{
...
public $messages = array();
...
if ($stmt->execute([$uid_new, $email_new, $pwd_1_hash])) {
$this->messages[] = 'success';
header('Location index.php');
}
messages.php
if ($registration->messages) {
foreach($registration->messages as $message) {
echo "$message <br>";
}
index.php
<?php include 'messages.php'; ?>
However after redirect, message is not showing up. Where can be a problem here? Thanks.