Hello!
I created a form with some required fields, “validate-email” fields, … and validation (mootools) was working well. But, after I having included some PHP code in “Form HTML” box, I send the form with required fields blank (or filled out incorrectly) and the validation don’t work.
For example, if I add the following code, I think the problem is on the line "$rows=$db->loadAssocList();", but I don’t understand why. I don’t know if the problem is the code or if there is any conflict...
How can I solve this problem? Or is there a best way of validating forms?
Thanks,
vsbr
I created a form with some required fields, “validate-email” fields, … and validation (mootools) was working well. But, after I having included some PHP code in “Form HTML” box, I send the form with required fields blank (or filled out incorrectly) and the validation don’t work.
For example, if I add the following code, I think the problem is on the line "$rows=$db->loadAssocList();", but I don’t understand why. I don’t know if the problem is the code or if there is any conflict...
<DIV class=form_item>
<DIV class="form_element cf_dropdown"><LABEL class=cf_label style="width: 100px;" >País</LABEL>
<?php
$db =& JFactory::getDBO();
$query = "SELECT * FROM #__paises";
$db->setQuery($query);
$rows = $db->loadAssocList();
?>
<SELECT class="cf_inputbox" style="width: 220px;" id=pais size=1 name=pais >
<?php
foreach ($rows as $row) {
if($row[nome] == "Portugal")
{ echo "<option value='$row[id]' selected>$row[nome]</option>"; }
else { echo "<option value='$row[id]'>$row[nome]</option>"; }
}
?>
</SELECT></DIV>
<DIV class=clear> </DIV></DIV>
How can I solve this problem? Or is there a best way of validating forms?
Thanks,
vsbr