Skip to Content Skip to Menu

🌲 Merry Christmas! Great savings on Professional and Developer Memberships! Get 25% off now with code XMAS-2024!

PHP Validator problem, with API

  • demis57
  • demis57
  • OFFLINE
  • Posts: 2
  • Thanks: 0
  • Karma: 0
18 years 8 months ago #10657 by demis57
PHP Validator problem, with API was created by demis57
Hello everybody!

I designed this function for validating my new users before inserting them in the DB. I also want to modify a little bit his info, puting e-mails in lowers, etc..

My problem is, that perhaps the "Echo" result shows the right way the variable should be, when their are saved in the DB, they have not being changed and they stayed as the user wrote them :S.

This is my code:

[code:1]function ValidacionRegistro(&$user,&$cbUser){
global $_POST, $_PLUGINS;

if(!preg_match ("/^[A-z0-9_-]+$/",$_POST)){
$_PLUGINS->raiseError(0);
$_PLUGINS->_setErrorMSG("Nombre de usuario no válido, éste puede contener únicamente letras, números y los caractéres guión(-) y subguión(_)"«»);
}

$_POST = trim(strtolower($_POST));
$_POST = trim(ucwords($_POST));
$_POST = trim(ucwords($_POST));
$_POST = trim(strtolower($_POST));

echo $_POST; //RESULT: myuser --> OK
echo $_POST; //RESULT: First Name -->OK
echo $_POST; //RESULT: Last Name --> OK
echo $_POST; // RESULT: email@email.com ->OK

return true;
}[/code:1]

Someone who could help me please??

Thanks

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum