easy navigation, making ID# display

hi! i want to make a navigation script where
i type in index.php?id=goo

and "goo" is displayed on the page.

how do you do that?well depending on if your register_globals are off it would be this way

index.php?id=goo


in your page
<?
echo $_GET["id"];
?>

if globals are on
<?
echo $id;
?>

register_globasl is a setting that is in the php.ini file and most of the time the host has control over it.i'm sure they are correct :).

how do i make it so only when someone types in "00-000-0000" digit it works.. if some types anything else, like 444, it will display and error message.what are you talking about now? and what is correct? the globals? those have to be OFF as that is correct.yes my php settings on fine :)

ok..

you know in the index.php?id=moo

well i want it to only let people visit

index.php?id=00-000-001

(in that format.. it could be 99-234-949 and others)

and anything else

like

index.php?id=LLALLS

will have an error messageI have no idea what you are trying to do. is that in a form? then you best bet is javascriptYou need to use regular expressions to check the syntax of the supplied id found in $_GET["id"]. There is a lot to learn about regular expressions, but accomplishing what you want shouldn't be hard. Just run a google search for 'regular expressions' and you will surely find some guides. functions in PHP like preg_match() and ereg() will do the validation for you, and return simple true or false values..eregi('^[0-9]{2}+-[0-9]{3}
+-[0-9]{3}$', $id)

will this accomplish how it detects?

will this be my code:

<?
echo $_GET["id"];

if $id = eregi('^[0-9]{2}+-[0-9]{3}
+-[0-9]{3}$', $id) {

echo $id;

}
else {

echo "Wrong format";

}
?>
 
Back
Top