phpquery Posted February 12, 2009 Share Posted February 12, 2009 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" Codes for validator.php 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 } } } Codes for email.php // Gather the data from the form, store it in variables $userEmail = $_POST['email']; $maxMessages = $_POST['maximum']; // Create a validator object require_once('validator.php'); $theValidator = new Validator(); // Validate the forms //$theValidator->validateNumber($userEmail, 'Email Address'); $theValidator->validateNumber($maxMessages, 'Maximum number of messages'); // Check whether the validator found any problems if ($theValidator->foundErrors()) { // The were errors, so report them to the user echo 'There was a problem with: '.$theValidator->listErrors('<br>'); // Show the errors, with a line between each } else { echo "All ok, so now add the user to the mailing list"; } Please guide me on a resolution to this query. Thanks in advance, phpquery [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/144895-error-in-email-validation/ Share on other sites More sharing options...
uniflare Posted February 12, 2009 Share Posted February 12, 2009 the function doesnt exist: foundErrors() Link to comment https://forums.phpfreaks.com/topic/144895-error-in-email-validation/#findComment-760358 Share on other sites More sharing options...
phpquery Posted February 12, 2009 Author Share Posted February 12, 2009 Hello, Thanks for your prompt response. Can you elaborate more on the response. I am not sure i understand. Do i need to make any edits to the codes? Thanks, phpquery Link to comment https://forums.phpfreaks.com/topic/144895-error-in-email-validation/#findComment-760359 Share on other sites More sharing options...
uniflare Posted February 12, 2009 Share Posted February 12, 2009 Are you sure you are the author of this code? It ust seems you lack the knowledge to of got this far; The error your getting is because you are calling a class method/function "if ($theValidator->foundErrors())" if this method is not in "SystemComponent.php" i the "systemcomponent" class then you need to add it and make it do what you want it to do. === The error is pretty self explanatory, you cant use a method that hasnt been made/set. Link to comment https://forums.phpfreaks.com/topic/144895-error-in-email-validation/#findComment-760363 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.