Checking if variable is null
Posted: Tue Nov 23, 2004 5:29 am
Hi Can anyone help me with the following code,
I have a form that has a mainly radio buttons but also a text box. When the form is submitted if the textbox is blank or empty I want the title text to turn red. If a value is held in the textbox it can remain blue. The variable connected to the text box is named $hours
here is the code I hae tried but wont work can anyone help, I think the error is to do with the isnull($hours and recognising is the variable holds a value
Thanks in advance
<?php if isnull($hours) && isset($submit) {
$not_complete = 1;
echo "RED";
echo "<td bgcolor='#CCD7FF'><font color='#FF0000' size='2' face='Arial, Helvetica, sans-serif'>";
echo "Your number of usual working hours per week over a period of at least 4 weeks, including both paid and unpaid overtime. ";
echo "</font></td>"; }
else
{
$not_complete = 0;
echo "Black";
echo "<td bgcolor='#CCD7FF'><font color='#000000' size='2' face='Arial, Helvetica, sans-serif'>";
echo "Your number of usual working hours per week over a period of at least 4 weeks, including both paid and unpaid overtime. ";
echo "</font></td>";
}
?>
I have a form that has a mainly radio buttons but also a text box. When the form is submitted if the textbox is blank or empty I want the title text to turn red. If a value is held in the textbox it can remain blue. The variable connected to the text box is named $hours
here is the code I hae tried but wont work can anyone help, I think the error is to do with the isnull($hours and recognising is the variable holds a value
Thanks in advance
<?php if isnull($hours) && isset($submit) {
$not_complete = 1;
echo "RED";
echo "<td bgcolor='#CCD7FF'><font color='#FF0000' size='2' face='Arial, Helvetica, sans-serif'>";
echo "Your number of usual working hours per week over a period of at least 4 weeks, including both paid and unpaid overtime. ";
echo "</font></td>"; }
else
{
$not_complete = 0;
echo "Black";
echo "<td bgcolor='#CCD7FF'><font color='#000000' size='2' face='Arial, Helvetica, sans-serif'>";
echo "Your number of usual working hours per week over a period of at least 4 weeks, including both paid and unpaid overtime. ";
echo "</font></td>";
}
?>