pilots Posted June 15, 2012 Report Share Posted June 15, 2012 Var kāds zinošs cilvēks palīdzēt ar kodu, pārbaudīt vai teksts sastāv tikai no burtiem+latviešu specifiskie, lieli mazi un cipari. Bez atstarpēm, bez simboliem utml.? Bez tiem latviešu elementāri itkā, bet nu šādi nākas jautāt pēc palīdzības. Paldies. Quote Link to comment Share on other sites More sharing options...
briedis Posted June 16, 2012 Report Share Posted June 16, 2012 Un ko tu pats esi uzrakstījis, kas ir sanācis, kur aizķeršanās? Quote Link to comment Share on other sites More sharing options...
gurkjis Posted June 16, 2012 Report Share Posted June 16, 2012 izmanto mb_* funkcijas, norādot utf-8 encodingu. Quote Link to comment Share on other sites More sharing options...
blackhalt Posted June 16, 2012 Report Share Posted June 16, 2012 Īsti nevar saprast mērķi un tā. Reku, Tev būs kaut kas: $evil_symbols=array( 'ā','č','ē','ģ','ī','ķ','ļ','ņ','š','ū','ž','Ā','Č','Ē','Ģ','Ī','Ķ','Ļ','Ņ','Š','Ū','Ž', 'а','б','в','г','д','е','ё','ж','з','и','й','к','л','м','н','о','п','р','с','т','у','ф','х','ц','ч','ш','щ','ъ','ы','ь','э','ю','я', 'А','Б','В','Г','Д','Е','Ё','Ж','З','И','Й','К','Л','М','Н','О','П','Р','С','Т','У','Ф','Х','Ц','Ч','Ш','Щ','Ъ','Ы','Ь','Э','Ю','Я','.'); Quote Link to comment Share on other sites More sharing options...
gurkjis Posted June 16, 2012 Report Share Posted June 16, 2012 ok, paskatījos googlē vai nav kāds gatavs skripts.. meklēju pēc atslēgvārdiem: php check allowed characters pirmajā linkā dabūju validācijas funkciju bez utf-8 chariem, pieliku latviešu simbolus un izskatās,ka strādā, bet jāpatestē kārtīgāk: function isValid($str) { return !preg_match('/[^A-Za-zā-ž0-9.#\\-$]/', $str); } var_dump(isValid('abķšČŌAc')); var_dump(isValid('abcфдсфд')); Quote Link to comment Share on other sites More sharing options...
daGrevis Posted June 16, 2012 Report Share Posted June 16, 2012 «ā-ž» neies. «ĀČĒĢĪĶĻŅŠŪŽāčēģīķļņšūž» Quote Link to comment Share on other sites More sharing options...
PANiK_ Posted September 9, 2014 Report Share Posted September 9, 2014 interesanti. man ir reģistrācijas forma, bet pagaidām es kā izsprūku ar strlen, bet strlen ieskaita space. kas man nav vajadzīgs. Man ir vēlme izmantot tikai latīņu burtus, punktus vai domuzīmes lietotājvārdos Mans Kods require_once("inc/db_connect.php"); session_start(); //Pārbaudam, vai lietotājs jau ir ielogojies if (isset ($_SESSION["id"], $_SESSION["login"])) { header("location: ./"); } //Registracija if(isset ($_POST["username"],$_POST["password"],$_POST["email"])) { $errors = array(); $username = $_POST["username"]; $firstname = $_POST["firstname"]; $lastname = $_POST["lastname"]; $password = sha1(md5($_POST["password"])); $email = $_POST["email"]; $reg_ip = $_SERVER["REMOTE_ADDR"]; $checku = mysqli_query($connect, "SELECT * FROM members WHERE username=\"$username\""); //Pārbaudam vai lietotājvārds jau nēeksistē if(mysqli_num_rows($checku) > 0) { $row = mysqli_fetch_array($checku); $username = $row['username']; //Chekojam lietotājvārdu $errors[] = "Username ".$username." is already taken."; } else { $checke = mysqli_query($connect, "SELECT * FROM members WHERE email=\"$email\""); if(mysqli_num_rows($checke) > 0) { //čekojam e-pastus $row = mysqli_fetch_array($checke); $email = $row['email']; $errors[] = "This email \" ".$email."\" is taken."; } else { if( strlen( $_POST['username'] ) < 6 ) { $errors[] = "Username is to short. Min caracter ir 6."; } else{ if(empty($errors) === true) { $query = mysqli_query($connect, "INSERT INTO members (id,username,first_name,last_name,password,email,reg_ip)VALUES ('','$username','$firstname','lastname','$password','$email','$reg_ip')"); header('Location: index.php?msg=signup_succesfull'); exit(); } } } } Kā lai es dabonu no space un tikai A-z, 0-9 un pukti ar domuzīmēm, jautājuma zīmēm izsaukuma zīmēm?? Quote Link to comment Share on other sites More sharing options...
indoom Posted September 9, 2014 Report Share Posted September 9, 2014 (edited) preg_match('/^[a-z\d\-.]{6,}$/i', $niks) Bet kāpēc neļaut rakstīt ko grib, nav jau 00tie vairs. Tāpat var sarakstīt -.-.-.-.- vai aaaaaaaaaa. Edited September 9, 2014 by indoom Quote Link to comment Share on other sites More sharing options...
PANiK_ Posted September 9, 2014 Report Share Posted September 9, 2014 Vienkārši man tā vajag+ tiks veidots vēl čekings lai vismaz sastav no 3 dažādiem latīņu simboliem. kautka ta. vel jadoma. Quote Link to comment Share on other sites More sharing options...
v3rb0 Posted September 9, 2014 Report Share Posted September 9, 2014 šķiet neko neesu palaidis garām - inc folderi vēl tikpat dzīvi kā sql injekcijas. Quote Link to comment Share on other sites More sharing options...
vbz Posted October 7, 2014 Report Share Posted October 7, 2014 interesanti. man ir reģistrācijas forma, bet pagaidām es kā izsprūku ar strlen, bet strlen ieskaita space. kas man nav vajadzīgs. Man ir vēlme izmantot tikai latīņu burtus, punktus vai domuzīmes lietotājvārdos Mans Kods require_once("inc/db_connect.php"); session_start(); //Pārbaudam, vai lietotājs jau ir ielogojies if (isset ($_SESSION["id"], $_SESSION["login"])) { header("location: ./"); } //Registracija if(isset ($_POST["username"],$_POST["password"],$_POST["email"])) { $errors = array(); $username = $_POST["username"]; $firstname = $_POST["firstname"]; $lastname = $_POST["lastname"]; $password = sha1(md5($_POST["password"])); $email = $_POST["email"]; $reg_ip = $_SERVER["REMOTE_ADDR"]; $checku = mysqli_query($connect, "SELECT * FROM members WHERE username=\"$username\""); //Pārbaudam vai lietotājvārds jau nēeksistē if(mysqli_num_rows($checku) > 0) { $row = mysqli_fetch_array($checku); $username = $row['username']; //Chekojam lietotājvārdu $errors[] = "Username ".$username." is already taken."; } else { $checke = mysqli_query($connect, "SELECT * FROM members WHERE email=\"$email\""); if(mysqli_num_rows($checke) > 0) { //čekojam e-pastus $row = mysqli_fetch_array($checke); $email = $row['email']; $errors[] = "This email \" ".$email."\" is taken."; } else { if( strlen( $_POST['username'] ) < 6 ) { $errors[] = "Username is to short. Min caracter ir 6."; } else{ if(empty($errors) === true) { $query = mysqli_query($connect, "INSERT INTO members (id,username,first_name,last_name,password,email,reg_ip)VALUES ('','$username','$firstname','lastname','$password','$email','$reg_ip')"); header('Location: index.php?msg=signup_succesfull'); exit(); } } } } Kā lai es dabonu no space un tikai A-z, 0-9 un pukti ar domuzīmēm, jautājuma zīmēm izsaukuma zīmēm?? tur nostrādās regulārais, express Vienkārši man tā vajag+ tiks veidots vēl čekings lai vismaz sastav no 3 dažādiem latīņu simboliem. kautka ta. vel jadoma Latīņu strādās: http://www.regexr.com/ Quote Link to comment Share on other sites More sharing options...
vbz Posted October 9, 2014 Report Share Posted October 9, 2014 http://php.net/manual/en/function.mb-ereg.php Quote Link to comment Share on other sites More sharing options...
rpr Posted October 9, 2014 Report Share Posted October 9, 2014 Vai tad nepietiek ar u modifieri preg_* funkciju paterniem? Quote Link to comment Share on other sites More sharing options...
vbz Posted October 9, 2014 Report Share Posted October 9, 2014 ja multibyte ieslēgts - pietiek, sapratīs arī ž un ā 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.