Zend - The PHP Company




Authentication

Add Code


Validator  

Type: code fragment
Added by: wibi
Entered: 25/06/2001
Last modified: 06/12/2000
Rating: **** (4 votes)
Views: 10035
If you create regfistartion form and you wanto to check wheter the login member exist, password verify check and valid email check, then this function will help you with perform those task.


<?
/********************************************************************
*    registration validation field function.
*    a function will check invalid char, verify password, existance login
*    and return the error message if occur, return null if validation succeed
*   Syntax :
*        - string validate (string login, string pass1, string pass2, string email);
*
*    Copyright (C) 2001 Wibisono Sastrodiwiryo. 
*       This program is free software licensed under the 
*       GNU General Public License (GPL).
*
*   CyberGL => Application Service Provider
*   http://www.cybergl.co.id
*    office@cybergl.co.id
*
*   $Id: validation.php3,v 1 2001/06/25 21:47:33 wibi Exp $ 
*********************************************************************/

function validate ($login$pass1$pass2$email) {
    global 
$tbl_member;
    if (
ereg("^[_a-z0-9-]+$",$login)) {
        if (
eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+([.][a-z0-9-]+)+$",$email)) {
            if (
$pass1 == $pass2) {
                
$owner=mysql_fetch_array(mysql_query("SELECT login FROM $tbl_member WHERE login='$login'"));
                if (
$owner[login]) {$err_msg="The Login "<b>$login</b>" exist";}
            } else {
$err_msg="Verify Password Failed";}
        } else {
$err_msg="Invalid Email";}
    } else {
$err_msg="Reserved Character";}
return 
$err_msg;
}
?>


Usage Example




Rate This Script





Search



This Category All Categories