1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Password Generator by PHP

Posted at
<html>
 <body>
  <table border="1" align="center">
   <form method="post" action="passgene.php">
   <tr><td>文字数</td><td><input type="text" size="10" name="chara_num"></td></tr>
   <tr><td>アルファベット小文字</td><td><input type="checkbox" name="small_letter"></td></tr>
   <tr><td>アルファベット大文字</td><td><input type="checkbox" name="capital_letter"></td></tr>
   <tr><td>数字</td><td><input type="checkbox" name="numeral_letter"></td></tr>
   <tr><td>特殊文字</td><td><input type="checkbox" name="special_letter"></td></tr>
   <tr slign="center"><td colspan="2"><input type="submit"></td></tr>
   </form>
  </table>

<?php
$num_char  = $HTTP_POST_VARS["chara_num"];
$sm_letter = $HTTP_POST_VARS["small_letter"];
$ca_letter = $HTTP_POST_VARS["capital_letter"];
$nu_letter = $HTTP_POST_VARS["numeral_letter"];
$sp_letter = $HTTP_POST_VARS["special_letter"];
$strin1 = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,";
$strin2 = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,";
$strin3 = "1,2,3,4,5,6,7,8,9,0,";
$strin4 = ">,<,#,$,%,&,-,/,[,],!,(,),=,~,^,|,{,},@,";
$judge  = 0;
$selected_array;
if($sm_letter=="on"){     $judge += 1;    }
if($ca_letter=="on"){     $judge += 10;   }
if($nu_letter=="on"){     $judge += 100;  }
if($sp_letter=="on"){ $judge += 1000; }
if($judge==1){
   $selected_array = $strin1;
}else if($judge==10){
   $selected_array = $strin2;
}else if($judge==11){
   $selected_array = $strin1.$strin2;
}else if($judge==100){
   $selected_array = $strin3;
}else if($judge==101){
   $selected_array = $strin3.$strin1;
}else if($judge==110){
   $selected_array = $strin3.$strin2;
}else if($judge==111){
   $selected_array = $strin3.$strin2.$strin1;
}else if($judge==1000){
   $selected_array = $strin4;
}else if($judge==1001){
   $selected_array = $strin4.$strin1;
}else if($judge==1010){
   $selected_array = $strin4.$strin2;
}else if($judge==1011){
   $selected_array = $strin4.$strin2.$strin1;
}else if($judge==1100){
   $selected_array = $strin4.$strin3;
}else if($judge==1101){
   $selected_array = $strin4.$strin3.$strin1;
}else if($judge==1110){
   $selected_array = $strin4.$strin3.$strin2;
}else if($judge==1111){
   $selected_array = $strin4.$strin3.$strin2.$strin1;
}

$strarray = explode(",",$selected_array,-1);
if(!$strarray){
   $str = "";
}else{
   for ($i = 0, $str = null; $i < $num_char; $i++) {
     $str .= $strarray[array_rand($strarray, 1)];
   }
}
?>

  <div align="center"><font size="7" color="Blue"><?php print($str); ?></font</div>
 </body>
</html>
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?