I have this (note that the text box is an array)
echo "<td><input style='width:60px' type='text' name='allocas[]' id='vtext' class='sc_two' size='80' maxlength='5'></td>
then in a validation code I have the following;
if(isset($_POST['Save']))
{
if($_POST['allocas']=='')
{
echo "<table border='1'><tr><td>mikies</td></tr></table>";
echo "Empty field";}
else
{
echo "<table border='1'><tr><td>mikies</td></tr></table>";
echo "Saved!";}
}
My issue is ($_POST['allocas']==''
doesn't seems to be doing the job as it doesn't validate and irrespective whether I have a value in allocas
or not it goes to 'else' validation and prints Saved!
.
If I change the text box from an array to a standalone text by changing the name to name='allocas'
instead of name='allocas[]'
then it works. So the issue is my validation of array values isn't correct and struggling to find an alternative approach. can you help?
Note : All these are not hard coded and dynamically populated. (live inside an echo
tag)
Thanks