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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:38:37+00:00 2026-05-28T07:38:37+00:00

I’m new to stackoverflow and to php and I’m trying to code this right.

  • 0

I’m new to stackoverflow and to php and I’m trying to code this right. What I am trying to do is eliminate the display of pages other than index.php but still include them by utilizing the address bar. For example, I’m trying to write a login script that includes a login.php file but handles all of the form’s post information and checks through the index.php file.

I’m trying to create a function to include only specific pages when called upon by the address bar. So the form’s action would be to index.php?act=login – I want to $_GET the act (login) and include login.php without the ability for users to include any other files that pose a security risk.

This is my code:

    function getContent() {

    $pages = array('login','page1');

    if(isset($_GET['act']) && $_GET['act'] == $pages) {
        include($_GET['act'] . '.php');
    } elseif (!isset($_GET['act'])) {
        echo 'INDEX PAGE';
    }
}

getContent();

Where am I going wrong? I can’t get the login.php page to display when index.php?act=login is set. The text “INDEX PAGE” displays just fine with act is not set.

  • 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-28T07:38:38+00:00Added an answer on May 28, 2026 at 7:38 am

    This line of code is your problem:

     if(isset($_GET['act']) && $_GET['act'] == $pages) {
    

    You need to change it to this (as you’re checking if the value of act exists in the array of pages):

    if(isset($_GET['act']) && in_array($_GET['act'], $pages)) {
    

    You might want to replace your elseif with a standard else, though. Because if $_GET['act'] is set, but isn’t in the array of pages, your elseif won’t be executed.

    Furthermore, I’d strongly recommend you using a micro-framework like Limonade, which will handle this for you (much more safely), once you feel more familiar with PHP.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to create an if statement in PHP that prevents a single post
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string

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.