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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:52:31+00:00 2026-05-23T11:52:31+00:00

For this moment using this code: if ($_GET[‘page’] == ‘index’ and file_exists(‘./intl/tpl/’ . $_GET[‘page’]

  • 0

For this moment using this code:

if ($_GET['page'] == 'index' 
     and file_exists('./intl/tpl/' . $_GET['page'] . '.tpl') 
     or !file_exists('./intl/tpl/' . $_GET['page'] . '.tpl') 
     or !$_GET['page']) {
//code
} elseif ($_GET['page'] == 'multi' 
          and file_exists('./intl/tpl/' . $_GET['page'] . '.tpl')) {
//code 2
}

and so on…

Question 1: Does this code “good” ? Doesn’t need any escaping or something ?

Question 2: ?page=logout doens’t work, so i created logout.php which looks like:

<?php
require_once "./intl/config.php";
SessionDelete('logged_in');
SessionDelete('username');
SessionDelete('userid');
if ($user_admin != null) {
    SessionDelete('inadmin');
    if (SessionGet('s_order') != null or SessionGet('s_page_show_all') != null) {
        SessionDelete('s_order');
        SessionDelete('s_page_show_all');
    }
}
header('Location: '.$config['indexurl'].'index.php');
?>

Maybe before sessions delete need session start and it’s possible do that with ?page=logout ?

  • 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-23T11:52:31+00:00Added an answer on May 23, 2026 at 11:52 am

    The code certainly can be improved:

    1. Reorder the tests so that it will not generate E_NOTICE errors
    2. Parenthesize so that operator precedence is immediately obvious
    3. Use the && and || boolean operators (as garvey’s comment says)

    Doing this, you ‘d have:

    if (empty($_GET['page']) ||
        !file_exists('./intl/tpl/' . $_GET['page'] . '.tpl') ||
        ($_GET['page'] == 'index' && file_exists('./intl/tpl/' . $_GET['page'] . '.tpl')) {
    //code
    }
    } elseif ($_GET['page'] == 'multi' && file_exists('./intl/tpl/' . $_GET['page'] . '.tpl')) {
    //code 2
    }
    

    Then, rewrite it some more to make it clear why you are doing what you do. This will also allow you to write simpler code. Simple is good.

    // This way it's obvious that 'index' is the default page
    $page = !empty($_GET['page']) ? $_GET['page'] : 'index';
    
    if (!file_exists('./intl/tpl/' . $page . '.tpl')) {
        $page = 'index'; // comment here saying that if a non-existing page is requested, we display the index instead
    }
    
    $template = './intl/tpl/' . $page . '.tpl';
    
    // At this point, we know that $page has a value, and we know that $template exists, so:
    switch($page) {
        case 'index':
            // code
            break;
        case 'multi':
            // code2
            break;
    }
    

    As for the second question: yes, you need to start the session before you are able to modify or destroy it.

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

Sidebar

Related Questions

At the moment my code looks like this: # Assign values for saving to
Take this example code (ignore it being horribly inefficient for the moment) let listToString
I'm using this code, to make a request to a given URL: private static
I am for the moment using the vanilla code examples and can't even get
At the moment I am using the following bit of code to only get
EDIT: I'm starting a bounty on this question. For the moment, I've moved on
Up to this moment I was using this types of methods to send some
I'm using this code: var nextLevel = (from p in cd.Objective where p.Parent_ObjectiveID ==
I've been using the code from this V3 example to set up a links
Till this moment I used this method to invoke: public string AddText { set

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.