emsy Posted April 1, 2010 Report Share Posted April 1, 2010 Es sāku veidot funkciju ar kuru pārbauda vai nikā nav kādu nevajadzīgu simbolu. <?php function valid_name($name) { if(preg_match("/^[a-zA-Z0-9]+/",$name)) { return true; } return false; } ?> It kā vajadzētu strādāt, bet visu laiku tiek returnots true Quote Link to comment Share on other sites More sharing options...
sandis_m Posted April 1, 2010 Report Share Posted April 1, 2010 tev taču tur rakstīts return true; Quote Link to comment Share on other sites More sharing options...
emsy Posted April 1, 2010 Author Report Share Posted April 1, 2010 (edited) Bet NEKAD nav ņemts vērā reurn false; Kkas nav kārtībā ar preg_match, jo es viņu nemāku izmantot :( Vajag tā, lai, ja vārdā ir kāds simbols, kas nav a-zA-Z0-9, tiek returnots false! Edited April 1, 2010 by emsy Quote Link to comment Share on other sites More sharing options...
2easy Posted April 1, 2010 Report Share Posted April 1, 2010 (edited) '/^[a-zA-Z0-9]+$/' Edited April 1, 2010 by 2easy Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.