Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $cone = new mysqli($host,$usua,$pass,$base);
- if ($cone->connect_errno) {
- echo "Falló la conexión a MySQL: (" . $cone->connect_errno . ") " . $cone->connect_error;
- }
- ?>
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
- <title> </title>
- </head>
- <body>
- <h1 align ="center">Bienvenido</h1>
- <a href ="index.html"><ol>Pagina Principal</ol></a>
- <a href ="registrar.php"><ol>Registrar</ol></a>
- <a href ="listado.php"><ol>Listado</ol></a>
- <a href ="Sancion.php"><ol>Sancion</ol></a>
- <form method="POST" action ="procesar.php">
- <label> Ingrese su nombre </label>
- <input type="text" name="nombre"><br/>
- <label> Ingrese su apellido </label>
- <input type="text" name="apellido"><br/>
- <label> Ingrese su cedula </label>
- <input type="text" name="cedula"><br/>
- <label> Ingrese su rango </label>
- <div><select name="rango">
- </select></div>
- <?php
- include "conexion.php";
- global $cone;
- $registros=mysqli_query($cone,"select * from rangos");
- while ($reg = mysqli_fetch_array($registros))
- echo '<option value="'.$reg[id_rango].'">'.$reg[rango].'</option>';
- ?>
- <input type="submit" value="enviar">
- </form>
- </body>
- </html>
- <?php
- require_once'conexion.php';
- include'funciones.php';
- bd_agregar($_REQUEST);
- ?>
- <html>
- <a href="index.html"> VOLVER </a>
- </html>
- <?php
- require_once'conexion.php';
- //Creamos función
- function bd_agregar($d){
- //Especificamos variable global.
- global $cone;
- //Obtenemos datos formulario
- $nombre = $_POST['nombre'];
- $apellido = $_POST['apellido'];
- $cedula = $_POST['cedula'];
- $rango = $_POST['rango'];
- //Insertamos datos
- $cone->query("INSERT INTO personal(nombre,apellido,cedula,rango_id) VALUES ('$nombre','$apellido','$cedula','$rango')");
- echo $nombre.$apellido.$cedula.$rango;
- //Comprobamos ejecución sentencia.
- if ($cone===false) {
- printf("Mensaje de error: %sn", $cone->error);
- } else {
- echo "Los datos se insertaron correctamente";
- $cone->close();
- global $cone;
- $registros=mysqli_query($cone,"select * from rangos");
- while ($reg = mysqli_fetch_array($registros))
- echo "<option value='"$reg[id_rango]"'>".$reg[rango]."</option>";
- echo "<option value='$reg[id_rango]'>".$reg[rango]."</option>";
- <?php
- require_once'conexion.php';
- //Creamos función
- function bd_agregar($d){
- //Especificamos variable global.
- global $cone;
- //Obtenemos datos formulario
- $nombre = $_POST['nombre'];
- $apellido = $_POST['apellido'];
- $cedula = $_POST['cedula'];
- $rango = $_POST['rango'];
- echo $nombre."<br/>".$apellido."<br/>".$cedula."<br/>".$rango."<br/>";
- //Insertamos datos
- $cone->query("INSERT INTO personal (nombre,apellido,cedula,rango_id) VALUES('$nombre','$apellido','$cedula','$rango')");
- //Comprobamos ejecución sentencia.
- if ($cone===false) {
- printf("Mensaje de error: %sn", $cone->error);
- } else {
- echo "Los datos se insertaron correctamente";
- }
- $cone->close();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement