Email validation

Hi, I am pretty new in PHP, I would like to integrate validate function in my code.

I got the code from the internet and copied it into my code, but somehow it doesn’t work on me. Can someone enlighten me ?

Here it goes the code,I copied it into my register.php

==========================================================
[php] [/php]

After that i have this email_validation.php with this :

[php]<?PHP
header(“Content-Type: text/html; charset=UTF-8”);
// Your PHP Function
class Validation {
private $EmailTester;

public function __construct(){  
    $this->EmailTester = '/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/';  
}  
public function validateEmail($email){  
    $test = preg_match($this->EmailTester, $email);  
    return $test;  
}  

}

$ajax = new PHPLiveX();

$myClass = new Validation();
$ajax->AjaxifyObjectMethods(array(“myClass” => array(“validateEmail”)));
// If validateEmail was a static function, you wouldn’t need to create an object:
// $ajax->AjaxifyClassMethods(array(“Validation” => array(“validateEmail”)));

$ajax->Run(); // Must be called inside the ‘html’ or ‘body’ tags
?> [/php]

======================================================

Your friendly advice would be highly appreciated.

Regards,
Matt

Sponsor our Newsletter | Privacy Policy | Terms of Service