...

View Full Version : Can't get URL Parameter to work.



trazix
11-11-2012, 02:03 PM
Using the link index.php?id=1 will work with the code bellow



if(isset($_GET['id']) && $_GET['id'] === '1') {

$url_parameter_id1 = $_REQUEST['id']; //REQUEST's parameter's from URL e.g id=?

PHP CODE HERE

}


However if i try index.php?id=12345 I just get the index.php page, how do i get it to accept id=12345 is a valid link and then use the parameter from the id to do something (e.g use it to refrence something in a database labled 12345)

trazix
11-11-2012, 02:21 PM
I think i figured it out .




if(isset($_GET['id']) && !empty( $_GET['id'] ) ) {

$url_parameter_id1 = $_REQUEST['id']; //REQUEST's parameter's from URL e.g id=?

PHP CODE HERE

}


I'd still like to know if this is correct way or if there is another way.

AndrewGSW
11-11-2012, 02:32 PM
You could stick with $_GET but it makes no real difference:


if (isset($_GET['id']) && !empty( $_GET['id'] ) ) {

$url_parameter_id1 = $_GET['id']; // parameter's from URL e.g id=?

PHP CODE HERE

}

dniwebdesign
11-11-2012, 08:34 PM
I typically use the following:

if(!empty($_GET['id']) && is_numeric($_GET['id'])) {

$url_parameter_id1 = $_GET['id']; //GET id query from URL (e.g id=?)

PHP CODE HERE

}


Which always works for me. :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum