Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. <?php
  2. $host="localhost";
  3. $usua="root";
  4. $pass="";
  5. $base="php_practica";
  6. $cone = new mysqli($host,$usua,$pass,$base);
  7.  
  8. if ($cone->connect_error) {
  9. die("Error de Conexion: " . $cone->connect_error);
  10. }
  11. ?>
  12.  
  13. <?php
  14. include ("conexion.php");
  15. ?>
  16. <!doctype html>
  17. <html>
  18. <head>
  19. <meta charset="utf-8">
  20. <title> </title>
  21. </head>
  22. <body>
  23. <form method = "POST" action = "procesar.php">
  24. <h1 align ="center">Bienvenido</h1>
  25. <a href ="index.html"><ol>Pagina Principal</ol></a>
  26. <a href ="registrar.html"><ol>Registrar</ol></a>
  27. <a href ="listado.html"><ol>Listado</ol></a>
  28. <a href ="Sancion.html"><ol>Sancion</ol></a>
  29. <div> Ingrese su nombre </div>
  30. <input type="text" name="nombre">
  31.  
  32. <div> Ingrese su apellido </div>
  33. <input type="text" name="apellido">
  34.  
  35. <div> Ingrese su cedula </div>
  36. <input type="text" name="cedula">
  37.  
  38. <div> Ingrese su rango </div>
  39. <div><select name="rango">
  40. <option value="1">First</option>
  41. <option value="2">Second</option>
  42. <option value="3">Third</option>
  43. </select></div>
  44. <input type="submit" value="enviar">
  45. </body>
  46. </html>
  47.  
  48. <?php
  49. include ("conexion.php");
  50. include ("funciones.php");
  51. ?>
  52.  
  53. <!doctype html>
  54. <html>
  55. <head>
  56. <meta charset="utf-8">
  57. <title> </title>
  58. </head>
  59. <body>
  60. <form method = "POST" action = "funciones.php">
  61. <?php
  62.  
  63. bd_agregar($_REQUEST);
  64. ?>
  65. </body>
  66. </html>
  67.  
  68. <?php
  69. include ("conexion.php");
  70.  
  71. function bd_agregar($temp){
  72. $nombre=$_REQUEST["nombre"];
  73. $apellido=$_REQUEST["apellido"];
  74. $cedula=$_REQUEST["cedula"];
  75. $rango=$_REQUEST["rango"];
  76. mysqli_query($cone,"INSERT INTO personal (nombre,apellido,cedula,rango)
  77. VALUES ('$nombre','$apellido','$cedula','$rango')");
  78. }
  79.  
  80.  
  81. //Revisar si guardo correctamente//
  82. if (mysqli_connect_errno($cone))
  83. {
  84. echo "Error al guardar los datos:" . mysqli_connect_error();
  85. }
  86. else
  87. {
  88. echo "Datos guardados correctamente:";
  89. }
  90.  
  91. mysqli_close($cone);
  92. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement