0

I want to set a message for the user to see in php, but I'm having issues crossing controllers. Here was my first try:

     if($revOutcome > 0){
         $message = "<p>Review updated!</p>";
         header('Location: /acme/accounts/index.php?action=seshLink');
         exit;
     }


And here was my second try:

     if($revOutcome > 0){
         header('Location: /acme/accounts/index.php?action=seshLink&message=Update was successful!');
         exit;
     }

I have an isset in the view that checks if $message is set, and if it is, echo what is displayed in $message. But for some reason, it's not displaying. Here is the code for the view:

<?php
if (isset($message)) {
echo $message;
}
?>

And here is the switch case statement seshLink:
case 'seshLink': $userId = $clientData['clientId']; $revData = getCliRev($userId);

    if(!$revData){
        $message = "<p>No reviews here yet. Write your first one today!</p>";
            include '../view/admin.php';
            exit;
    }
        else {
            $RevDisplay = buildAdminReviewDisplay($revData);
        }

  include '../view/admin.php';
  break;

I really don't know why $message isn't displaying.

3
  • 1
    Because you are making a request call (parameters through url) which means that you need to get your variables using $_GET array like if (isset($_GET["message"])) Commented Jul 14, 2017 at 5:04
  • @JorgeCampos That worked!! Thank you! I'd be happy to accept your answer too :)!! Commented Jul 14, 2017 at 5:07
  • 1
    Glad that it worked. Done. Commented Jul 14, 2017 at 5:08

1 Answer 1

2

Because you are making a request call (parameters through url) which means that you need to get your variables using $_GET array like

...
if (isset($_GET["message"]))
   ...
Sign up to request clarification or add additional context in comments.

1 Comment

echo $_GET["message"];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.