On Thu, Dec 11, 2008 at 05:30, Xaver Thum <[email protected]> wrote:
>
> But if I specify a hex color like #CC0000 instead of "red",
>
> <a href="http://www.anyurl.com?mypar=17&color=#CC0000"> ...
>
> the color is ignored (probably because # starts a PHP comment).
> Is there any workaround for this problem ?
Hey, X;
Actually, it's skipped because it's seen as a page anchor. That's
a client-side only thing, and the browser would then be looking for:
<a name="CC0000" id="CC0000"></a>
Instead, skip the hashmark:
<a href="http://www.anyurl.com/?mypar=17&color=CC0000"> ...
.... and have it parsed similarly to this:
<?php
if(strlen($_GET['color']) == 6 &&
preg_match('/[a-f0-9]{6}/i',trim($_GET['color']))) {
// Color is a legitimate HTML hexadecimal color
$_GET['color'] = strtoupper($_GET['color']); // Set upper-case
} else {
// Color is not legit, was not supplied, or this may be a lame
hack attempt
$_GET['color'] = 'CC0000'; // Force default color
}
$color = '#'.$_GET['color'];
?>
--
</Daniel P. Brown>
http://www.parasane.net/
[email protected] || [email protected]
50% Off Hosting! http://www.pilotpig.net/specials.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php