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

The Archive Base Latest Questions

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

In my login.php page I have this: $allowed_operations = array(‘foo’, ‘lorem’); if(isset($_GET[‘p’]) && in_array(isset($_GET[‘p’]),

  • 0

In my login.php page I have this:

$allowed_operations = array('foo', 'lorem');
    if(isset($_GET['p']) 
    && in_array(isset($_GET['p']), $allowed_operations)){
    switch($_GET['p']){
        case 'foo':
              // Code for 'foo' goes here
        break;
        case 'lorem':
             // Code for 'lorem' goes here
        break;
    }
}

Where if I call the url http://example.com/login.php?p=foo the function foo is called.

Is it possible I can call this url without adding a href http://example.com?p=foo in my html markup?

For example something likes this:

<?php

if (array_key_exists("login", $_GET)) {
    $p = $_GET['p'];
    if ($p == 'foo') {
       header("Location: login.php?p=foo");  // This doesn't work
                        // And if I remove the ?p=foo, 
                        // it redirect to the page but
                        // the 'foo' function is not called
        }
    }

    ?>

and my html:

<a href="?login&p=foo">Login Foo</a> <br />
  • 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-31T07:24:38+00:00Added an answer on May 31, 2026 at 7:24 am

    this is because of the infinite page redirect loops. that will be created by your code.

    $p = $_GET['p'];
        if ($p == 'foo') {
           header("Location: login.php?p=foo");  // This doesn't work
                            // And if I remove the ?p=foo, 
                            // it redirect to the page but
                            // the 'foo' function is not called
            }
        }
    

    every time you execute the code in this page the condition will be set to true, that is $_GET['p'] will always hold the value foo and it will redirect again and again to the same page. detecting which PHP will stop executing your script.

    I am unable to understand on why you would want to redirect to the same page again, even if the condition is met. my suggestion is to avoid it. simply check if the variable wants to redirect to the same page if yes. then skip the page if not then redirect to the preferred destination.

    if (array_key_exists("login", $_GET)) {
        $p = $_GET['p'];
        if ($p == 'foo') {
          //sice the variable foo redirects to the same page skip this path and do nothing
        } else {
            //any other url redirection goes here
            header('Location: index.php?bar');
        }
    }
    

    while there might be other way. the above code should also work, and will avoid getting into infinite page redirect loop.

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

Sidebar

Related Questions

On my index page I have a link to my login.php page with this
so I have a simple login page like this: <fieldset> <legend>Verification</legend> <form method=post action=authentication.php>
I have some problem with the injecting of my cookie into login.php page. This
I have this php page that posts to itself and then it checks weather
I have now changed my login system from session_register() to this: UPDATE : <?php
I'm loading a simple page using: $.get('../admin/login.php', function(data) { $('#box-contents').html(data); }); Now, on this
I have a (HTTPS) login.php page which remains HTTPS (ie once user logged in
I have this in my PHP code, and it currently does the login request
I have this on my login page: $current_time = date("g:i A"); $current_date = date("l,
i have this code in indexSucces.php //some html for the main page <td width='48%'

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.