<?php
function form_validation($last_name, $first_name, $email, $password, $password_conf, $usuario) {
if($first_name == '' || $last_name == '' || $email == '' || $usuario == '' ||
$password == '' || $password_conf == '') {
return 'You must fill all the fields.';
} else if($password != $password_conf) {
return 'The password and it\'s confirmation are different.';
} else if(!check_email($email)) {
return 'The email address is incorrect.';
} else{
return 'valid';
}
}
function register_user($last_name, $first_name, $email, $password, $username) {
$reg =& new Collection('userslist');
$lista_campos = array("last_name" => $last_name, "first_name" => $first_name, "email" => $email, "username" => $username, "password" => $password);
$reg->add_item('user', $lista_campos);
$reg->save();
}
function check_email($email) {
$regex =
'^'.
'[_a-z0-9-]+'. /* One or more underscore, alphanumeric,
or hyphen charactures. */
'(\.[_a-z0-9-]+)*'. /* Followed by zero or more sets consisting
of a period and one or more underscore,
alphanumeric, or hyphen charactures. */
'@'. /* Followed by an "at" characture. */
'[a-z0-9-]+'. /* Followed by one or more alphanumeric
or hyphen charactures. */
'(\.[a-z0-9-]{2,})+'. /* Followed by one or more sets consisting
of a period and two or more alphanumeric
or hyphen charactures. */
'$';
return eregi($regex, $email);
}
?>
|