Array's and Conditional's
Posted: Mon Aug 08, 2005 9:24 am
I decided "Hmm, let's get rid of this little hole in my script!" And what is that hole mind you? Conditional isset functions!
Example:
http://www.example.com/page.php?variable=notsomething
Choices are either something or somethingelse... You type in notsomething... But the script should default to something if variable doesn't equal either something or somethingelse.
My feeble attempt didn't go as planned... I'm missing something.
Example:
http://www.example.com/page.php?variable=notsomething
Choices are either something or somethingelse... You type in notsomething... But the script should default to something if variable doesn't equal either something or somethingelse.
My feeble attempt didn't go as planned... I'm missing something.
Code: Select all
// Conditional Setcookie - Theme
if (isset($HTTP_COOKIE_VARS['the']) AND empty($HTTP_GET_VARS['the'])) {
$the = $HTTP_COOKIE_VARS['the'];
} elseif (isset($HTTP_GET_VARS['the'])) {
$arr = array('erd','gra','ora','fli','low','ros','see');
if($the == $arr) {
$the = $HTTP_GET_VARS['the'];
setcookie('the',$the, time()+60*60*24*30);
} else {
setcookie('the','gra', time()+60*60*24*30);
$the = 'gra';
}
} else {
setcookie('the','gra', time()+60*60*24*30);
$the = 'gra';
}