<form method="post" action="">
<input type="submit" value="Generate" name="Generate">
</form>
<?
if(!isset($ssnin)){
$letter[0] = rand(1,8);
for($a=1;$a<12;$a++){
$letter[$a] = rand(0,9);
}
for($i=0;$i<13;$i++){
$multi[$i] = (13-$i) * $letter[$i];
}
$summ = array_sum($multi);
$c = $summ%11;
if($c>2){$d = 11-$c;}else{$d=$c;}
$letter[12] = $d;
$tssn = $letter[0].$letter[1].$letter[2].$letter[3].$letter[4].$letter[5].$letter[6].$letter[7].$letter[8].$letter[9].$letter[10].$letter[11].$letter[12];
print("Generated SSN for Thai is : ");
print("<font color=red>".$tssn."</font>");
}
?>
<HR>
<!-- Verify section -->
<center>VERIFIED SSN?</center><BR>
<form method="post" action="">
SSN : <input type="text" size="13" name="ssnin" value="<?print($tssn)?>">
<input type="submit" value="Verified" name="submit">
</form>
<?
if(isset($ssnin)){
$summary = 0;
for($i=0;$i<12;$i++){
$summary = $summary + $ssnin[$i]*(13-$i);
}
$summary = $summary%11;
if($summary >2){$dumm = 11-$summary ;}else{$dumm=$summary ;}
if($dumm == $ssnin[12]){
print("SSN : ".$ssnin." is VALID");
}else if($dumm != $ssnin[12]){
print("SSN : ".$ssnin." is NOT VALID......last number must be ".$dumm );
}
}
?>
Thursday, May 08, 2008
online Thai ssn generator and verifier
Labels: generator, php, ssn, thai serial number, thai ssn