Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> strlen() co jest do cholery?
lukass
post
Post #1





Grupa: Zarejestrowani
Postów: 72
Pomógł: 0
Dołączył: 20.03.2002

Ostrzeżenie: (0%)
-----


Witam

chcialem zrobic sprawdzanie dlugosci hasla (z formularza) za pomoca strlen(), tylko ze to cholerstwo wogole nie wyciaga ilosci znakow, jest puste.

Ma ktos jakas teorie na to? Albo lepszy sposob na sprawdzanie dlugosci znakow z input'a?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
lukass
post
Post #2





Grupa: Zarejestrowani
Postów: 72
Pomógł: 0
Dołączył: 20.03.2002

Ostrzeżenie: (0%)
-----


(IMG:http://forum.php.pl/style_emoticons/default/smile.gif) ok wiec czesc odpowiadajaca za autentyfikacje:

[php:1:8d43cbe0cf]<?php

if ($fun=="user_add")
{
#kontrola parametrow

#sprawdz czy haslo poprawnie podane
if ($ppassword==$ppassword2)
{
#to samo maile
if ($pemail==$pemail2)
{
#sprawdz czy nie ma takiego usera w bazie danych
$zap=mysql_query("select * from pasazer where login='$plogin';");
$ile_rek=mysql_num_rows($zap);
mysql_free_result($zap);

if ($ile_rek>0)
{
print "<p class=blad>Podany użytkownik już istnieje!<br></p>";
#wlacz formularz do poprawy
$fun="user_correct_form";
#ktore pole zaznaczyc jako zle
$zlepole=1;
}else{

#jesli allOK to dodaj rekord

$zap=mysql_query("insert into pasazer (login,password,mail) values ('$plogin','$ppassword','$pemail');");
if ($zap)
{
print "<center><table>";
print "<tr><th colspan=2><font class=naglowek>Twoje dane:</font></td></tr>";
print "<tr><td class=tableft>Login</td><td class=naglowek>$plogin</td></tr>";
print "<tr><td class=tableft>Haslo</td><td class=naglowek>$ppassword</td></tr>";
print "<tr><td class=tableft>E-Mail</td><td class=naglowek>$pemail</td></tr>";
print "<tr><th colspan=2><a href=index.php3 class=naglowek>Zaloguj sie</a></td></tr>";

}else{
print "<p class=blad>Nie mogę dodać użytkownika!<br></p>";
}
}
}else{
print "<p class=blad>Podane adresy e-mail nie są zgodne!<br></p>";
$fun="user_correct_form";
$zlepole=2;
}
}else{
print "<p class=blad>Podane hasła nie są zgodne!<br>Bądź są za krotkie.</p>";
$fun="user_correct_form";
$zlepole=3;
}

}

?>[/php:1:8d43cbe0cf]

A tu sam formularz:

[php:1:8d43cbe0cf]<?php

if ($fun=="new_user")
{
#nowy user
print "<form name=logowanie action=index.php3 method=post>";
print "<input type=hidden name=fun value=user_add>";
print "<center><table>";
print "<tr><th colspan=2><font class=naglowek>Wpisz swoje dane:</font></td></tr>";
print "<tr><td class=tableft>Login</td><td><input name=plogin></td></tr>";
print "<tr><td class=tableft>Hasło</td><td><input type=password name=ppassword></td></tr>";
print "<tr><td class=tableft>Hasło (potwierdź)</td><td><input type=password name=ppassword2></td></tr>";
print "<tr><td class=tableft>E-Mail</td><td><input name="pemail"></td></tr>";
print "<tr><td class=tableft>E-Mail (potwierdź)</td><td><input name="pemail2"></td></tr>";
print "<tr><th colspan=2 align=right><input type=submit value='Zapisz'></td></tr>";
print "</table>";
}


?>[/php:1:8d43cbe0cf]

Probowalem tak (wstawic zamiast linii 8 pierwszego kodu):

Kod
if ((strlen($ppassword)>4) && ($ppassword==$ppassword2))
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 7.10.2025 - 02:01