Contenidos
Código en PHP que permite almacenar tres valores que se envían mediante el método POST (datos.php)
1 2 3 4 5 |
<?php $fh = fopen("valores.txt", 'a') or die("Se produjo un error al crear el archivo"); fwrite($fh, htmlentities($_POST['fecha']) . '|' . htmlentities($_POST['longitude']) . '|' . htmlentities($_POST['latitude']) . PHP_EOL) or die("No se pudo escribir en el archivo"); fclose($fh); ?> |
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 |
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> <script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script> </head> <body> <script> var date = new Date(); navigator.geolocation.getCurrentPosition((posicion) => { $.post("https://www.jesusninoc.com/xxx123.php", { fecha: date , latitude : posicion.coords.latitude, longitude : posicion.coords.longitude }, (response) => { console.log(response.results); }); }); </script> </body> </html> |