Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Biglietto del cinema</title>
  4. <?php
  5. //funzioni
  6. function convGio($Gio){
  7.  
  8. if($Gio<10)
  9. return "0".$Gio;
  10.  
  11. return $Gio;
  12.  
  13. }
  14.  
  15. function conveMes($mes){
  16.  
  17. switch($mes){
  18. case 1: return "A"; break;
  19. case 2: return "B"; break;
  20. case 3: return "C"; break;
  21. case 4: return "D"; break;
  22. case 5: return "E"; break;
  23. case 6: return "F"; break;
  24. case 7: return "G"; break;
  25. case 8: return "H"; break;
  26. case 9: return "I"; break;
  27. case 10: return "L"; break;
  28. case 11: return "M"; break;
  29. case 12: return "N"; break;
  30. default: break;
  31. }
  32. }
  33.  
  34.  
  35.  
  36. function consonanti($s)
  37. {
  38. $s=strtoupper($s);
  39. $cons="";
  40. for($i=0;$i<strlen($s);$i++)
  41. { $car=substr($s,$i,1);
  42. if($car>="A" && $car<="Z")
  43. if(!( ($car=="A") ||($car=="E") ||($car=="I") ||($car=="O") ||($car=="U")) )
  44. $cons=$cons .$car;
  45. }
  46. return $cons;
  47. }
  48.  
  49. function vocali($s)
  50. {
  51. $s=strtoupper($s);
  52. $voc="";
  53. for($i=0;$i<strlen($s);$i++)
  54. { $car=substr($s,$i,1);
  55. if($car>="A" && $car<="Z")
  56. if( ($car=="A") ||($car=="E") ||($car=="I") ||($car=="O") ||($car=="U") )
  57. $voc=$voc .$car;
  58. }
  59. return $voc;
  60. }
  61. ?>
  62. </head>
  63. <body>
  64. <?php
  65. if(!isset($_GET["cognome"] ) || !isset($_GET["nome"]) || !isset($_GET["giorno"]) || !isset($_GET["mese"]) || !isset($_GET["anno"]) || !isset($_GET["scelta"]) ){
  66. die("<h1>Per favore compila tutti i campi</h1>");
  67. }
  68. $scelt=$_GET["scelta"];
  69. $an=$_GET["anno"];
  70. $mes=$_GET["mese"];
  71. $gio=$_GET["giorno"];
  72. $cogn=$_GET["cognome"];
  73. $nome=$_GET["nome"];
  74. echo "<h1>$cogn $nome il tuo codice &egrave; </h1>";
  75.  
  76. if($scelt==2)
  77. $gio=$gio+40;
  78. $gio=convGio($gio);
  79.  
  80. $codcogn=substr(consonanti($cogn). vocali($cogn). "X",0,3);
  81. if( strlen(consonanti($nome)) <=3)
  82. $codnome=substr(consonanti($nome). vocali($nome). "X",0,3);
  83. else
  84. $codnome=substr(consonanti($nome),0,1).substr(consonanti($nome),2,2);
  85. $an=substr($an,2,3);
  86. $mes=conveMes($mes);
  87.  
  88.  
  89. echo "<h2>$codcogn$codnome$an$mes$gio</h2>"
  90. ?>
  91. </body>
  92. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement