Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Biglietto del cinema</title>
- <?php
- //funzioni
- function convGio($Gio){
- if($Gio<10)
- return "0".$Gio;
- return $Gio;
- }
- function conveMes($mes){
- switch($mes){
- case 1: return "A"; break;
- case 2: return "B"; break;
- case 3: return "C"; break;
- case 4: return "D"; break;
- case 5: return "E"; break;
- case 6: return "F"; break;
- case 7: return "G"; break;
- case 8: return "H"; break;
- case 9: return "I"; break;
- case 10: return "L"; break;
- case 11: return "M"; break;
- case 12: return "N"; break;
- default: break;
- }
- }
- function consonanti($s)
- {
- $s=strtoupper($s);
- $cons="";
- for($i=0;$i<strlen($s);$i++)
- { $car=substr($s,$i,1);
- if($car>="A" && $car<="Z")
- if(!( ($car=="A") ||($car=="E") ||($car=="I") ||($car=="O") ||($car=="U")) )
- $cons=$cons .$car;
- }
- return $cons;
- }
- function vocali($s)
- {
- $s=strtoupper($s);
- $voc="";
- for($i=0;$i<strlen($s);$i++)
- { $car=substr($s,$i,1);
- if($car>="A" && $car<="Z")
- if( ($car=="A") ||($car=="E") ||($car=="I") ||($car=="O") ||($car=="U") )
- $voc=$voc .$car;
- }
- return $voc;
- }
- ?>
- </head>
- <body>
- <?php
- if(!isset($_GET["cognome"] ) || !isset($_GET["nome"]) || !isset($_GET["giorno"]) || !isset($_GET["mese"]) || !isset($_GET["anno"]) || !isset($_GET["scelta"]) ){
- die("<h1>Per favore compila tutti i campi</h1>");
- }
- $scelt=$_GET["scelta"];
- $an=$_GET["anno"];
- $mes=$_GET["mese"];
- $gio=$_GET["giorno"];
- $cogn=$_GET["cognome"];
- $nome=$_GET["nome"];
- echo "<h1>$cogn $nome il tuo codice è </h1>";
- if($scelt==2)
- $gio=$gio+40;
- $gio=convGio($gio);
- $codcogn=substr(consonanti($cogn). vocali($cogn). "X",0,3);
- if( strlen(consonanti($nome)) <=3)
- $codnome=substr(consonanti($nome). vocali($nome). "X",0,3);
- else
- $codnome=substr(consonanti($nome),0,1).substr(consonanti($nome),2,2);
- $an=substr($an,2,3);
- $mes=conveMes($mes);
- echo "<h2>$codcogn$codnome$an$mes$gio</h2>"
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement