Jump to content

error in email validation


phpquery

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.