error in email validation
Posted: Wed Feb 11, 2009 2:46 am
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"
email.php
Please guide me on a resolution to this query.
Thanks in advance,
phpquery
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.phpCode: 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\">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\"> </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\"> </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\"> </li><li style=\"\" class=\"li2\"> // The were errors, so report them to the user</li><li style=\"\" class=\"li1\"> </li><li style=\"\" class=\"li2\"> echo 'There was a problem with: '.$theValidator->listErrors('<br>'); // Show the errors, with a line between each</li><li style=\"\" class=\"li1\"> </li><li style=\"\" class=\"li2\">}</li><li style=\"\" class=\"li1\">else</li><li style=\"\" class=\"li2\">{</li><li style=\"\" class=\"li1\"> </li><li style=\"\" class=\"li2\"> echo "All ok, so now add the user to the mailing list";</li><li style=\"\" class=\"li1\"> </li><li style=\"\" class=\"li2\">}</li><li style=\"\" class=\"li1\"> </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