Hello, i am trying to create a php script that offers the following functions...

wardrobe.php?friend=FRIENDNAME
wardrobe.php?hash=HASHTAG

but i dont want you to be able to use both at the same time, please could you help improve my code to become more stable, add error checking and also offer this feature mentioned above, thanks

<?

header("Content-Type: image/png");

$friend = strtolower($_GET['friend']);
$hash = strtolower($_GET['hash']);

if (empty($hash) {

$filepath = "wardrobe/md5($friend)";
$errorpath = "wardrobe/cb5e100e5a9a3e7f6d1fd97512215282";

if (is_readable($filepath)) {
	readfile($filepath);
} else {
	readfile($errorpath);
}	

} elseif (empty($friend) {

$filepath = "wardrobe/$hash";
$errorpath = "wardrobe/cb5e100e5a9a3e7f6d1fd97512215282";

if (is_readable($filepath)) {
	readfile($filepath);
} else {
	readfile($errorpath);
}	

}

?>

Kind Regards,
Nathaniel Blackburn

Recommended Answers

All 2 Replies

you may try

wardrobe.php?key=hash&value=HASHTAG
or
wardrobe.php?key=friend&value=FRIENDNAME

your code file may look like

<?

header("Content-Type: image/png");

$value = strtolower($_GET['value']);

if( strtolower($_GET['value'])=='hash')
   $filepath = "wardrobe/$value";

else if( strtolower($_GET['value'])=='friend')
   $filepath = "wardrobe/md5($value)";
else
   exit;

$errorpath = "wardrobe/cb5e100e5a9a3e7f6d1fd97512215282";

if (is_readable($filepath)) {
	readfile($filepath);
} else {
	readfile($errorpath);
}	




?>

thanks but i managed to fix it myself :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.