0

I need to redirect the user in this code example, so I don't have a option. But I want to make a Box visible, when the result is success, but I can't echo the visibility by the ID, and I can't find a second option for that.

if ($result == "success") {
                header('Location: https://www.example.com/lorem');
                echo '<style>#successbox { visibility: visible !important;}</style>';
            } else {
                header('Location: https://www.example.com/lorem');
                echo '<style>#errorbox { visibility: visible !important;}</style>';
            };

1 Answer 1

0

you need to handle this on the second page "https://www.example.com/lorem" by passing a variable in get parameter ex : https://www.example.com/lorem?success=1

and at the second page 'www.example.com/lorem' you can add a condition

if (isset($_GET["success"])){
  if($_GET["success"])
    echo '<style>#successbox { visibility: visible !important;}</style>';
  else 
   echo '<style>#errorbox { visibility: visible !important;}</style>';
}

or by adding it at a session variable ex: $_SESSION["success"] = 1;

if (isset($_SESSION["success"])){
  if($_SESSION["success"])
    echo '<style>#successbox { visibility: visible !important;}</style>';
  else 
   echo '<style>#errorbox { visibility: visible !important;}</style>';
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.