Can you query the URL without an INC file?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Can you query the URL without an INC file?

Post by simonmlewis »

I need pass the ID number of a person to a PHP page.

Normally I would do this:

Code: Select all

index.php?page=home&id=2
So it would pick 2 from a $_REQUEST.
But I don't need another inc file, I need it to work like this:

Code: Select all

index.php&id=2
Is there a way to use the $_REQUEST without an include file - ie. directly from the PHP source??

Simon
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Can you query the URL without an INC file?

Post by jackpf »

I don't understand...why can't you use the code you posted first?
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Can you query the URL without an INC file?

Post by simonmlewis »

It's because the script that checks their status is called loginstatus.php, and I want the page where they have to subcribe, to be subscribe.php.

One has to be passed to the other.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Can you query the URL without an INC file?

Post by jackpf »

So...you're including two files? And you want them both to be able to access the same ID?

When you include a file, it's given the variable/function scope of the parent file, so it will have access to $_GET['id'].

Is this what you mean?
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

[RESOLVED] Re: Can you query the URL without an INC file?

Post by simonmlewis »

Hi, I have actually worked it out myself now.

If you have $id = $_REQUEST['id']; at the start of the posted to page, and the redirect says subscribe.php?id=2, then it works a treat.

Simon
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Post Reply