Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 768485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:11:22+00:00 2026-05-14T18:11:22+00:00

I have a custom class that, when called, will redirect to a page and

  • 0

I have a custom class that, when called, will redirect to a page and send a ‘message_type’ and ‘message’ variable via GET. When the page opens it checks for these variables and displays a ‘success’, ‘warning’, or ‘error’ message depending on the ‘message_type’ variable. I made it so the user thinks they stay on the same page. It also allows for other variables to be passed along with the message.

Is this good practice, or should I just start using exceptions?

Example:

//Call a static function that will redirect to a page, with an error message
RedirectWithMessage::go('somepage.php', MessageType::ERROR, 'Error message here.');

The following checkMessage() function is an include file:

function checkMessage()
{
    if((isset($_GET['message_type']) && strlen($_GET['message_type'])) && (isset($_GET['message']) && strlen($_GET['message_type'])))
    {
        DisplayMessage::display($_GET['message_type'], $_GET['message']);
        return true;
    }
    return false;
}

On the page that is redirected to, call checkMessage();

//If a message is received, display it. If not, do nothing
checkMessage();

I know this might be vague, and I can supply more code if necessary. I guess the issue is that I don’t have much experience using exceptions, but I think they seem cumbersome (writing try-catch blocks everywhere). Please let me know if I am making this more difficult for myself or if there is a better solution.

Thanks!
Mike

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T18:11:23+00:00Added an answer on May 14, 2026 at 6:11 pm

    I think it’s a good way to do it, I do something very similar, although I store the relevant error info in their session ($_SESSION) instead, and clear it right after it’s displayed. That keeps it out of the query string, and makes it so if they refresh the page the error goes away

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.