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 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 am a very proficient C# developer, but need to start writing code that
I'm writing some code that looks like this: while(true) { switch(msg->state) { case MSGTYPE:
I'm writing some code that has a lot of substitution. There's a list<char> productions
I am writing some code that connects to a website, and using C#, and
I am writing some code that needs to be backwards compatible with EXISTING remoting
I'm writing some code that takes a report from the mainframe and converts it
I'm writing some code that uses some unmanaged calls into user32 functions such as
I have been writing some code that creates a generic blog. Its features are
I'm very familiar with using a transaction RDBMS, but how would I make sure
I'm looking at writing some code that performs shadow mapping, in DX9. The sample

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.