Display diffrent text depending on url

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
User avatar
dclamp
Forum Commoner
Posts: 35
Joined: Sun Sep 17, 2006 10:05 am

Display diffrent text depending on url

Post by dclamp »

Hi,

what i am looking for is when some one looks at my page "error.php?err=1" it will show whatever i have set for that. same with other numbers as well. i hope that is not confusing...

thanks in advanced!
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Something simple:

Code: Select all

<?

// here's where you set your errors
$errorArray[1] = "There is an error!";
$errorArray[2] = "This is another error!";
$errorArray[3] = "Ugh, yet another";

if(is_numeric($_GET['err'])) { // check that $_GET['err'] is numeric, and not a hijack attempt
	if(!empty($errorArray[$_GET['err']])) { // check that this error number exists
		echo "ERROR: " . $errorArray[$_GET['err']]; // print the error
	}
}

?>
User avatar
dclamp
Forum Commoner
Posts: 35
Joined: Sun Sep 17, 2006 10:05 am

Post by dclamp »

the error message is going to have contain alot of info. will it still work with that code?
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Post by daedalus__ »

Why wouldn't it?
Post Reply