...

View Full Version : index.php?abc ... how to get the name of "abc"



gabba
05-28-2007, 09:10 PM
Hi!

This is my first message on coding forums, but I've been 'hanging out' here for a while now. I'd definitely classify myself as a beginner in PHP, but I'm learning and I learn by example so codingforums has definitely helped me out loads so far. I can't wait until I can give back to the community that's helped me so much.

I am just experimenting in PHP at the moment, but I was wondering if it is possible to capture any variables that come in to a page that are not specific, or assigned?

Like:

index.php?abcdef

or

index.php?microsoft

or

index.php?special+sauce

Would it be possible to detect that "abcdef" is in the URI (or URL.. I don't know which term to use)?

Thanks for your help!
Gabba

felgall
05-28-2007, 09:54 PM
Those would be the name of a field that doesn't have a value.

GCharb
05-28-2007, 10:04 PM
Hi!

This is my first message on coding forums, but I've been 'hanging out' here for a while now. I'd definitely classify myself as a beginner in PHP, but I'm learning and I learn by example so codingforums has definitely helped me out loads so far. I can't wait until I can give back to the community that's helped me so much.

I am just experimenting in PHP at the moment, but I was wondering if it is possible to capture any variables that come in to a page that are not specific, or assigned?

Like:

index.php?abcdef

or

index.php?microsoft

or

index.php?special+sauce

Would it be possible to detect that "abcdef" is in the URI (or URL.. I don't know which term to use)?

Thanks for your help!
Gabba
Hello there!

Not sure about what u want but have a look at this code, might do it for you!


<body>
<?
$ref = getenv("HTTP_REFERER");
if( strstr( $ref, "abcde" )) {
echo "abcde is part of the url!";
}
?>
<form action="test.php?abcde" method="post" name="form1">
Submit a form :
<input name="submit" type="submit" value="Submit" />
</form>
</body>

Charb

firepages
05-28-2007, 11:48 PM
<?echo $_SERVER['QUERY_STRING']?> would return 'abc'
or
<?
$tmp = array_keys($_GET);
print_r($tmp);
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum