0

I'm using PHP, Smarty, MySQL for my website. I have an array of error messages and I want to use this array in a PHP file to which I'm redirecting the control. However, I'm not understanding how should I achieve this.

code is as follows:

$error_msg  = $contact_us->GetAllErrors();
$smarty->assign('error_msg', $error_msg);
$return_url = "view_contact_us.php?page=".$_SESSION['contact_us']."&from_date={$from_date}&to_date={$to_date}&contact_full_name={$contact_full_name}&contact_label={$hidden_contact_label}&error_msg=".$error_msg;
header("Location:".$return_url);

I tried many different ways, but I'm not able to use the array $error_msg in the file view_contact_us.php.

If I print the array $error_msg it looks like following:

   Array
(
    [error_msgs] => Please select at least one enquiry
Please select at least one enquiry label
)
Phlume
  • 3,075
  • 2
  • 19
  • 38
PHPLover
  • 1
  • 51
  • 158
  • 311

1 Answers1

0

You can use $_SESSION variable and put or assign your array() as its value.

For example:

$arr = array();

$arr[0] = "error_1";
$arr[1] = "error_2";
$arr[2] = "error_3";

$_SESSION['errorMsg'] = $arr;

After that, $_SESSION['errorMsg'] can now be use globally throughout all webpages.

Kiel Labuca
  • 1,223
  • 9
  • 13