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

  • Home
  • SEARCH
  • 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 6147353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:05:47+00:00 2026-05-23T19:05:47+00:00

I am writing a code that I am sure is very simple, but for

  • 0

I am writing a code that I am sure is very simple, but for some reason I am having trouble. It seems like it would be logical to write it out as it is. If the $_GET != $arr then return false with an error.

The situation is we give two different groups a code, there are three codes in all. The third code is a catch all that takes them to a form that is un-modified, so it is an initial value or will be. The other two take them to two different forms that is assigned to each code.

What I am trying to get to do is if they enter the code correct then fine it redirects them, if they do not enter anything they get an error that says sorry you must enter your code. If they enter it wrong an error that says check your code and try again or call this number for help.

The error is where I am having trouble creating. If you would help me figure out how to validate the $_GET form to the arrays and if it comes out false to pop out the error.

   <?php

$arr = array(001,002,003);
    if ($_GET['code'] === "001") {
        header("Location: http://stackoverflow.com/");      
    }
    if ($_GET['code'] === "002") {
        header("Location: http://gaming.stackexchange.com/");
    }
    if ($_GET['code'] === "003") {
        header("Location: http://gamedev.stackexchange.com/");
    }
if ($_GET ['code'] != $arr); 
else {
echo("Uh oh, you did not enter the correct code error message");
}
?>
</head>

<body>
<form id="galaonly" name="galaonly" method="get" action="">
  <input name="code" type="text" value="001" size="50" maxlength="150" />
  <input type="submit" value="Submit" />
</form>
  • 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-23T19:05:48+00:00Added an answer on May 23, 2026 at 7:05 pm
    <?php
    if(isset($_GET['code'])){
        $arr = array('001', '002', '003');
    
        if(in_array($_GET['code'], $arr, true)){
            if($_GET['code'] === '001'){
                header("Location: http://stackoverflow.com/");
            } elseif($_GET['code'] === '002') {
                header("Location: http://gaming.stackexchange.com/");
            } elseif($_GET['code'] === '003'){
                header("Location: http://gamedev.stackexchange.com/");
            }
        } else{
            echo 'Uh oh, you did not enter the correct code error message';
        }   
    }
    ?>
    
    </head>
    
    <body>
    <form id="galaonly" name="galaonly" method="get" action="">
      <input name="code" type="text" value="001" size="50" maxlength="150" />
      <input type="submit" value="Submit" />
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing some code that handles logging xml data and I would like to
I'm writing some code that id like to be able to work with any
I find myself writing code that looks like this a lot: set<int> affected_items; while
I'm writing some code that uses dynamic shared libraries as plugins. My command line
On Fedora Core 7, I'm writing some code that relies on ARG_MAX . However,
I'm writing some server code that talks to a client process via STDIN. I'm
I have been writing some code that creates a generic blog. Its features are
I'm writing code that looks similar to this: public IEnumerable<T> Unfold<T>(this T seed) {
I am writing code that checks for the permission to write to and delete
In writing the code that throws the exception I asked about here , I

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.