1 | <!DOCTYPE html> |
2 | <html lang="es"> |
3 | |
4 | <head> |
5 | |
6 | <meta charset="UTF-8"> |
7 | <meta name="viewport" content="width=device-width"> |
8 | |
9 | <title>Servicio que procesa un formulario con token</title> |
10 | |
11 | <script type="module" src="lib/js/consumeJson.js"></script> |
12 | <script type="module" src="lib/js/submitForm.js"></script> |
13 | <script type="module" src="lib/js/muestraError.js"></script> |
14 | |
15 | </head> |
16 | |
17 | |
18 | |
19 | <body onload="consumeJson('srv/registra.php') |
20 | .then(token => forma.token.value = token.body) |
21 | .catch(muestraError)"> |
22 | |
23 | <form id="forma" onsubmit="submitForm('srv/procesa.php', event) |
24 | .then(resultado => { |
25 | alert(resultado.body) |
26 | location.href = 'index.html' |
27 | }) |
28 | .catch(muestraError)"> |
29 | |
30 | <h1>Servicio que procesa un formulario con token</h1> |
31 | |
32 | <p><a href="index.html">Cancela</a></p> |
33 | |
34 | |
35 | <input type="hidden" name="token"> |
36 | |
37 | <p> |
38 | <label> |
39 | Saludo: |
40 | <input name="saludo"> |
41 | </label> |
42 | </p> |
43 | |
44 | <p> |
45 | <label> |
46 | Nombre: |
47 | <input name="nombre"> |
48 | </label> |
49 | </p> |
50 | |
51 | <p> |
52 | <button type="reset">Restaurar</button> |
53 | <button type="submit">Procesa</button> |
54 | </p> |
55 | |
56 | </form> |
57 | |
58 | </body> |
59 | |
60 | </html> |