check email/username for FEU

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
JeremyBASS

check email/username for FEU

Post by JeremyBASS »

In this example $_GET['cntnt01fbrp__39'] is an ajax call from formbuilder... You would/could change the get to email or something.

ex:Check Email .. This also suggest some valid alternates... ie if you are not using an email for the user name then you would want to give the alternates...

a UDT put on a page...

Code: Select all

global $gCms;
$FEU = $gCms->modules['FrontEndUsers']['object'];


// A FUNCTION TO TEST FOR A VALID EMAIL ADDRESS, RETURN TRUE OR FALSE 
function check_valid_email($email){ 
    // IS THE PATTERN OF THE EMAIL ADDRESS OK? 
    if (!preg_match('/^[A-Z0-9_-][A-Z0-9._-]*@([A-Z0-9][A-Z0-9-]*\.)+[A-Z]{2,6}$/i', $email)) return FALSE; 
    // IS THE DOMAIN OF THE EMAIL ADDRESS ROUTABLE OVER THE INTERNET FOR MX OR A RECORDS? 
    $emaila = explode('@', $email); 
    if ( checkdnsrr($emaila[1],"MX") || checkdnsrr($emaila[1],"A") ) return TRUE; 
    // NOT ROUTABLE 
    return FALSE; 
} 

if (!empty($_GET['cntnt01fbrp__39'])){ 
    $e = $_GET['cntnt01fbrp__39']; 
    if (check_valid_email($e)){ 
        echo "<br/>VALID: $e \n"; 
		if($FEU->GetUserID($e)){
			$e1=$e;
			while ($FEU->GetUserID($e1)) {
				$e1=$e.rand(5, 100);
			}
			$e2=$e.rand(5, 100);
			while ($FEU->GetUserID($e2)) {
				$e2=$e.rand(5, 100);
			}
			echo '<span style="color:red">This is not available</span> <span style="color:green">'.$e1.' and '.$e2.' is available</span>';
			return 'false';
		}else{
			echo "<br/>AVAILABLE: $e \n"; 
			return 'true';
		}
    }else{ 
        echo "<br/>BOGUS: $e \n"; 
		return 'false';
    } 
} 




Cheers
Jeremy Bass
Last edited by JeremyBASS on Sun Jan 17, 2010 7:03 pm, edited 1 time in total.
Post Reply

Return to “Tips and Tricks”