-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphp_27.php
More file actions
47 lines (41 loc) · 1.22 KB
/
Copy pathphp_27.php
File metadata and controls
47 lines (41 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<!DOCTYPE html>
<html lang="en">
<head>
<title>NIE/NIF</title>
</head>
<body>
<form method="post" action="php_27.php">
<select name="IdentificadorFiscal">
<option value="NIF">NIF</option>
<option value="NIE">NIE</option>
</select>
Introdueix NIE/NIF: <input type="text" name="identificadorFiscal"><br>
<input type="submit" value="Envia"/>
</form>
<?php
if (isset($_POST['IdentificadorFiscal'])){
$identificadorFiscal=$_POST['IdentificadorFiscal'];
}else{
$identificadorFiscal="";
}
if (isset($_POST['identificadorFiscal'])){
$IdFiscal=$_POST['identificadorFiscal'];
if ($identificadorFiscal=="NIF"){
$numero = substr($IdFiscal,0,8);
$lletra = substr($IdFiscal,8,1);
//mostrar els numeros i les lletres per separat
echo "<br>"."Numeros: $numero"."<br>". "Lletres: $lletra";
}
if ($identificadorFiscal=="NIE"){
$lletra1 = substr($IdFiscal,0,1);
$numero = substr($IdFiscal,1,7);
$lletra2 = substr($IdFiscal,8,1);
//mostrar els numeros i les lletres per separat
echo "<br>"."Numeros: $numero"."<br>"."Lletres: $lletra1.$lletra2";
}
}else{
$IdFiscal=" ";
}
?>
</body>
</html>