Skip to Content Skip to Menu

🌟 CB Editor Assistant 1.0.0 is here! Discover our new AI Joomla Plugin that wrote its story! (and this banner!)
Start at just $12.50/month* or 💸 save 30% with our 🛍️ Intro Black Friday Offer for a lifetime*

PHP Validator problem, with API

  • demis57
  • demis57
  • OFFLINE
  • Posts: 2
  • Thanks: 0
  • Karma: 0
18 years 7 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