Advertisement
eimkasp

php asm kodas

Mar 4th, 2012
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.01 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4.  
  5. if ($_POST) {
  6.  
  7. $kodas = $_POST["kodas"];
  8.  
  9. function birthday ($birthday){
  10.  
  11. list($year,$month,$day) = explode("-",$birthday);
  12.  
  13. $year_diff = date("Y") - $year;
  14.  
  15. $month_diff = date("m") - $month;
  16.  
  17. $day_diff = date("d") - $day;
  18.  
  19. if ($day_diff < 0 || $month_diff < 0)
  20.  
  21. $year_diff--;
  22.  
  23. return $year_diff;
  24.  
  25. }
  26.  
  27. if(strlen($kodas) != 0 && strlen($kodas) > 10){
  28.  
  29. $metai = substr($kodas, 1,2);
  30.  
  31. $menesis = substr($kodas, 3,2);
  32.  
  33. $diena = substr($kodas, 5,2);
  34.  
  35.  
  36.  
  37. $text = "Zmogus gime 19".$metai." - ".$menesis." men. - ".$diena." d. <br /> Dabar jam ".birthday("19".$metai."-".$menesis."-".$diena."")." metu";
  38.  
  39.  
  40.  
  41. } else {
  42.  
  43. $text = "Klaida! neivestas asmens kodas arba per trumpas";
  44.  
  45. }
  46.  
  47.  
  48.  
  49. }
  50.  
  51.  
  52.  
  53. ?>
  54.  
  55.  
  56.  
  57. <html>
  58.  
  59. <head>
  60.  
  61. <title>Pavadinbimas</title>
  62.  
  63. </head>
  64.  
  65. <body>
  66.  
  67.  
  68.  
  69.  
  70.  
  71. <form method="post" action="" >
  72.  
  73. Asmens kodas: <input type="text" name="kodas" /><br/ >
  74.  
  75. <br />
  76.  
  77. <input type="Submit" />
  78.  
  79. </form>
  80.  
  81.  
  82.  
  83. <?php echo $text; ?>
  84.  
  85.  
  86.  
  87. </body>
  88.  
  89.  
  90.  
  91. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement