I would like to display many session messages on one page. The first page is file_upload.php
// Success!
echo "File was uploaded without errors.<br />" . $_SESSION['message'];
echo "File name is '{$file_name}'.<br />" . $_SESSION['message'];
echo "File references an uploaded file. <br />" . $_SESSION['message'];
echo "File was uploaded without errors" . $_SESSION['message'];
Second file is new.php here is $sql = "INSERT INTO products ";
(cat_id, prod_name, filename, type, size, filename2, type2, size2, position, visible, content)
$result = insert_products($products);
if($result === true) {
$new_id = mysqli_insert_id($db);
$_SESSION['message'] = 'The product has been created.';
redirect_to(url_for('/staff/pages/show.php?id=' . $new_id));
The third is show.php and here is the function.
<?php echo display_session_message(); ?>
function get_and_clear_session_message() {
if(isset($_SESSION['message']) && $_SESSION['message'] != '') {
$msg = $_SESSION['message'];
unset($_SESSION['message']);
return $msg;
}
}
function display_session_message() {
$msg = get_and_clear_session_message();
if(!is_blank($msg)) {
return '<div id="message">' . h($msg) . '</div>';
}
}
For now, only shows in show.php 'The product has been created' message. Is it possible to display many session messages on one page? I want to add all error message form function file_upload.php.