I made a page where users can input a Hex Code for different colors they want to change on their page. It all works fine, but I would like to make it so if the box the user is inputting to is empty, then display the default CSS. Otherwise, display a custom one.
I'll use an example:
The users choice gets sent to a form validation:
$this->form_validation->set_rules('channelNameColor',
lang('user_themes_channel_name_color'),
'trim|strip_tags|xss_clean|min_length[6]|max_length[6]');
Then it eventually gets passed to a file where it can be used in CSS:
It is declared here:
$channelNameColor = $theme['channelNameColor'];
Then down below all those declarations it gets put in as CSS:
.channelNameBar h1{
font-size:20px;
color:#<?=$channelNameColor?>;
float: left;
}
I would like to do something like this:
<?php
if (empty($channelNameColor)){
echo ".channelNameBar h1{";
echo "font-size:20px;";
echo "color:#FFFFFF;";
echo "float: left;";
echo "}";
}
else
{
echo ".channelNameBar h1{";
echo "font-size:20px;";
echo "color:#$channelNameColor;";
echo "float: left;";
echo "}";
}
?>
But it is not recognizing $channelNameColor in: if (empty($channelNameColor)){
Why is it not recognizing it there, but it recognizes it fine when I use it in the css? Sorry if this is a very simple question to answer, I'm pretty new to PHP
var_dump($channelNameColor)emptyfunction, it does notis_numeric|exact_length[6].