Advertisement
yagami07

Crear

Feb 25th, 2018
3,379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title></title>
  4. </head>
  5. <body>
  6. <center>
  7. <h1> .: Crear Persona :. </h1>
  8. <hr>
  9. <a href="../">Home</a> |
  10. <a href="index.php">Atrás</a>
  11. <hr>
  12.  
  13. <?php
  14. // Preguntando si llegaron datos por metodo GET
  15. if ($_GET) {
  16.  
  17. // Capturando los datos q llegaron
  18. $nom = $_GET['nom'];
  19. $dir = $_GET['dir'];
  20. $tel = $_GET['tel'];
  21. $ema = $_GET['ema'];
  22. $fec = $_GET['fec'];
  23.  
  24. // Conectar con el servidor y seleccioné a bd
  25. $con = new mysqli('localhost', 'root', '', 'adsi120_121');
  26.  
  27. // Creando la consulta
  28. $sql = "INSERT INTO Personas
  29. VALUES(null, '$nom', '$dir', '$tel', '$ema', '$fec')";
  30.  
  31. // ejecutando la consulta
  32. $resultado = $con->query($sql);
  33.  
  34. if ($resultado == true) {
  35. // echo "Registro insertado exitosamente!<br><br>";
  36. header('location: index.php');
  37. }else{
  38. echo "Error!";
  39. }
  40.  
  41. }
  42.  
  43. ?>
  44.  
  45. <form>
  46. <input required name="nom" placeholder="Nombre"><br><br>
  47. <input required name="dir" placeholder="Direccion"><br><br>
  48. <input required type="number" name="tel" placeholder="Telefono"><br><br>
  49. <input required type="email" name="ema" placeholder="E-mail"><br><br>
  50. <input required type="date" name="fec" placeholder="Fecha de Nacimiento"><br><br>
  51. <input type="submit" value="DADS">
  52. </form>
  53.  
  54. </center>
  55. </body>
  56. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement