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 893179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:10:45+00:00 2026-05-15T14:10:45+00:00

I have a bit of a problem with my PHP code, I am assigning

  • 0

I have a bit of a problem with my PHP code, I am assigning values to variables in different states of the flow depending on what I receive, but for some reason it keeps getting stuck at one point, here is the code.

if (isset($session)) {  
    //if the user is in the database
    if ($row == 1) {

        $from = $_GET['from'];

            if (isset($from)) { 

                $page = $_GET['page'];

                switch ($page) {
                    case "game":

                        $page = "game";
                        sendVars($page);//send the variable

                        break;
                    case "gallery":

                        $page = "gallery";
                        sendVars($page);//send the variable

                        break;
                    case "leaderboard":

                        $page = "leaderboard";
                        sendVars($page);//send the Variable                     
                        break;

                }
        }else {             
                $page = "game";

                sendVars($page);//send the variable
            }

        //if the user is not in the database
        }else {

            //do this
        }

} else {

    //register
}

Now for some odd reason, it keeps setting the value of $page to game, even though I set the page variable to gallery like so http://www.mydomai.com/?from=set&page=gallery . the only reason for this that I can think of is that my switch is not working as it should? or it is bypassing the switch somehow?

Thanx in advance!

  • 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-15T14:10:46+00:00Added an answer on May 15, 2026 at 2:10 pm

    I just ran your code after removing a few of the unessersary variable assignments:

    <?php
    
    // I added this function just for testing
    function sendVars($page) {
      echo $page;
    }
    
    if (isset($_GET['from'])) {
    
      $page = $_GET['page'];
    
      switch ($page) {
        case "game":
          sendVars($page); //send the variable
    
          break;
        case "gallery":
          sendVars($page); //send the variable
    
          break;
        case "leaderboard":
          sendVars($page); //send the Variable
          break;
      }
    } else {
      $page = "game";
    
      sendVars($page); //send the variable
    }
    

    And it all seems fine, xxx.php?from=1&page=gallery echos out “gallery”, try doing a print_r($_GET) at the top of your script and see what it prints out and let us know.

    On a side note I think the below may be shorter for you and still do the same thing:

    if (isset($_GET['from'])) {
      // Check if $_GET['page'] exsists and is either game, gallery or leaderboard
      if (isset($_GET['page']) && in_array($_GET['page'], array('game', 'gallery', 'leaderboard')))
        sendVars($_GET['page']);
    }
    else
      sendVars('game');
    

    I hope this helps

    Cheers
    Luke

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

Sidebar

Related Questions

I have some problem convert C++ code to PHP. The purpose is I need
I have a bit of a problem that I can't seem to code my
I have a problem. i want to send some data to my iframe.php file..
** Solved ** I have a bit of a problem with my code i
I have some PHP AJAX code that is supposed to validate some parameters sent
Hey guys, I have a bit of a problem. I get values from textarea
I have created a PHP code which compresses mp3 while uploaded to 32kbps bit
I'm having a bit of an issue trying to get some PHP code to
I have a bit of problem when trying to validate my page as HTML5.
I have a bit of a problem. I am trying to do the following

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.