ForumPortaliGalleryPytėsoriKėrkoLista AnėtarėveGrupet e AnėtarėveRegjistrohuidentifikimi

Share | 
 

 [Tutorial]Krijoni Password Generator ne PHP

Shko poshtė 
AutoriMesazh
Xhulio
Moderator/e
Moderator/e
avatar

Numri i postimeve : 357
Registration date : 27/07/2008

MesazhTitulli: [Tutorial]Krijoni Password Generator ne PHP   Sun Aug 10, 2008 4:07 pm

Ne kete tutorial do te mesojme si te krijojme ne Password Generetor ne PHP.

Se pari krijojme nje dokument dhe vendosim nje forme , si me poshte :
Kodi:

echo "<td>";
echo "<form action='passwordgenerator.php' method='post'/>";
echo "Gjatesia e passwordit: <input type='text' name='length'/><br />";
echo "<input type='submit' name='submit' value='Gjenero'/>";
echo "</form>";
echo "</td>";

Dhe me pas do te bejme nje dokument ku te programojme se ne qoftse nuk shkruhen karaktere jo numerike apo nuk shkruhet asnje karkter te shfaqet nje mesazh qe tregon qe edhe invalid.

Se pari vendosim kete disajn te thjeshte:

Kodi:
<?php
echo "<table style='border: 1px solid #000;' tableborder='0px'>";

Dhe me pas vendosim nje funksion shfaq gabimin invalid :

Kodi:
function writePassword(){
  $length = $_POST['length'];
  $characters = abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ;

Me pas edhe kete funksion i cili merr passwordin dhe e gjeneron:

Kodi:
srand((double)microtime()*1000000);
for ($i=0;$i<$length;$i++)
$password = $password . substr ($characters, rand() % strlen($characters), 1);
 echo "<tr><td>";
  echo "Passwordi i gjeneruar:<br />";
echo "</td><td><b>";
if(!$i){
echo "Gabim";
}
  echo $password;
echo "</b></td>";
}

Kodin e meposhtem vendoseni pas kodit te cekur me lart :

Kodi:
if($_POST['submit']){
echo writePassword();
echo "</tr></td>";
}

Kodi perfundimtar eshte :

Kodi:
<?php
echo "<table style='border: 1px solid #000;' tableborder='0px'>";
 function writePassword(){
  $length = $_POST['length'];
  $characters = abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ;
srand((double)microtime()*1000000);
for ($i=0;$i<$length;$i++)
$password = $password . substr ($characters, rand() % strlen($characters), 1);
 echo "<tr><td>";
  echo "Your randomly generated password:<br />";
echo "</td><td><b>";
if(!$i){
echo "Invalid";
}
  echo $password;
echo "</b></td>";
}
echo "<b><font size='18px'>Fierce's Password Generator</font></b>";
echo "<br />";
if($_POST['submit']){
echo writePassword();
echo "</tr></td>";
}
echo "<td>";
echo "<form action='passwordgenerator.php' method='post'/>";
echo "Length of Password: <input type='text' name='length'/><br />";
echo "<input type='submit' name='submit' value='Create'/>";
echo "</form>";
echo "</td>";
?>
Mbrapsht nė krye Shko poshtė
Shiko profilin e anėtarit
 
[Tutorial]Krijoni Password Generator ne PHP
Mbrapsht nė krye 
Faqja 1 e 1

Drejtat e ktij Forumit:Ju nuk mund ti pėrgjigjeni temave tė kėtij forumi
AlbaOne :: Informatika, Shkarkime :: Gjuhe programuese :: PHP & MySQL-
Kėrce tek: