Page 1 of 1

error in email validation

Posted: Wed Feb 11, 2009 2:46 am
by phpquery
Hello,

Please have a look at the following codes & attached screen shots.

When we enter details in the fields mentioned in the screen shot named "email_html" & click on OK then it gives me an error as shown in the screen shot named "email_validation_error"

Code: Select all

validator.php

Code: Select all

</li><li style=\"\" class=\"li1\">require_once 'SystemComponent.php';</li><li style=\"\" class=\"li2\">class validator extends SystemComponent {</li><li style=\"\" class=\"li1\">var $errors; </li><li style=\"\" class=\"li2\">// A variable to store a list of error messages</li><li style=\"\" class=\"li1\">function validateNumber($theinput,$description = '')</li><li style=\"\" class=\"li2\">{</li><li style=\"\" class=\"li1\">if (is_numeric($theinput)) </li><li style=\"\" class=\"li2\">{</li><li style=\"\" class=\"li1\">return true; // The value is numeric, return true</li><li style=\"\" class=\"li2\">}</li><li style=\"\" class=\"li1\">else</li><li style=\"\" class=\"li2\">{</li><li style=\"\" class=\"li1\">$this->errors[] = $description; // Value not numeric! Add error description to list of errors</li><li style=\"\" class=\"li2\">return false; // Return false</li><li style=\"\" class=\"li1\">}</li><li style=\"\" class=\"li2\">}</li><li style=\"\" class=\"li1\">}</li><li style=\"\" class=\"li2\"></li><li style=\"\" class=\"li1\"></li><li style=\"\" class=\"li1\"></li><li style=\"\" class=\"li1\">
  email.php

Code: Select all

</li><li style=\"\" class=\"li1\">// Gather the data from the form, store it in variables</li><li style=\"\" class=\"li2\">$userEmail = $_POST['email'];</li><li style=\"\" class=\"li1\">$maxMessages = $_POST['maximum'];</li><li style=\"\" class=\"li2\">// Create a validator object</li><li style=\"\" class=\"li1\">require_once('validator.php');</li><li style=\"\" class=\"li2\">$theValidator = new Validator();</li><li style=\"\" class=\"li1\">&nbsp;</li><li style=\"\" class=\"li2\">// Validate the forms</li><li style=\"\" class=\"li1\">//$theValidator->validateNumber($userEmail, 'Email Address');</li><li style=\"\" class=\"li2\">$theValidator->validateNumber($maxMessages, 'Maximum number of messages');</li><li style=\"\" class=\"li1\">&nbsp;</li><li style=\"\" class=\"li2\">// Check whether the validator found any problems</li><li style=\"\" class=\"li1\">if ($theValidator->foundErrors())</li><li style=\"\" class=\"li2\">{</li><li style=\"\" class=\"li1\">&nbsp;</li><li style=\"\" class=\"li2\">&nbsp; &nbsp; // The were errors, so report them to the user</li><li style=\"\" class=\"li1\">&nbsp;</li><li style=\"\" class=\"li2\">&nbsp; &nbsp; echo 'There was a problem with: '.$theValidator->listErrors('<br>'); // Show the errors, with a line between each</li><li style=\"\" class=\"li1\">&nbsp;</li><li style=\"\" class=\"li2\">}</li><li style=\"\" class=\"li1\">else</li><li style=\"\" class=\"li2\">{</li><li style=\"\" class=\"li1\">&nbsp;</li><li style=\"\" class=\"li2\">&nbsp; &nbsp; echo "All ok, so now add the user to the mailing list";</li><li style=\"\" class=\"li1\">&nbsp;</li><li style=\"\" class=\"li2\">}</li><li style=\"\" class=\"li1\">&nbsp;</li><li style=\"\" class=\"li2\"></li><li style=\"\" class=\"li2\"></li><li style=\"\" class=\"li2\"></li><li style=\"\" class=\"li2\">


Please guide me on a resolution to this query.

Thanks in advance,

phpquery

Re: error in email validation

Posted: Wed Feb 11, 2009 3:31 am
by Ziq
Do you think it is a normal code? I cannot understand that you have written...

In any case this type of errors means that you didn't create the "foundErrors" method in your "validator" class. Check this class.

Re: error in email validation

Posted: Wed Feb 11, 2009 6:02 am
by phpquery
Hi Ziq,

Thanks for a prompt response. I checked the class & everything looks ok to me. I am pasting the codes once again for your reference. I appreciate your time on trying to resolve my issue.

Code: Select all

 
require_once 'SystemComponent.php';
class validator extends SystemComponent {
var $errors; 
// A variable to store a list of error messages
function validateNumber($theinput,$description = '')
{
if (is_numeric($theinput)) 
{
return true; // The value is numeric, return true
}
else
{
$this->errors[] = $description; // Value not numeric! Add error description to list of errors
return false; // Return false
}
}
}
 
Thanks,

phpquery

Re: error in email validation

Posted: Wed Feb 11, 2009 11:49 am
by phpquery
Hello Friends,

Just following up to see if any one got time to look at my issue & can guide me to a resolution.

Thanks,

phpquery

Re: error in email validation

Posted: Wed Feb 11, 2009 11:59 am
by John Cartwright
Where do you see foundErrors() defined?

In the future, please do not bump your thread within 24 hours.