Pregunta:
Fecha: 18-09-2016 14:21:14
(En Español)
Problema con subir a base de datos un formulario[Resuelta]
Me podrían ayudar es un problema con subir a base de datos un formulario. Estoy usando este codigo para subir un formulario a una base de datos de mysql pero cuando le doy registrar no lo procesa ni carga los archivos quisiera saber si hay algun error en el codigo.<?php
$referencia=$_POST['referencia'];
$estado=$_POST['estado'];
$mantenimiento=$_POST['mantenimiento'];
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "proyecto_sena";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection fallida: " . $conn->connect_error);
}
$sql = "INSERT INTO equipos_de_la_empresa (referencia, estado, mantenimiento)
VALUES ('$referencia', '$estado', '$mantenimiento')";
if ($conn->query($sql) === TRUE) {
echo "se registro correctamente";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
por si necesitan el html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>InterConnect</title>
</head>
<body>
<div align="center">InterConnect s.a.s </div>
<table height="116" align="center">
<tr>
<td height="21">
<form id="equipos" name="equipos" method="post" action="jairoscript.php"> </form>
</td>
<tr>
<td>
<div>
<label for="referencia">Referencia del equipo: </label>
<input type="text" name="referencia" id="referencia" />
</div>
</td>
</tr>
<tr>
<td>
<div>
<label for="estado">Estado del equipo: </label>
<select name="estado" id="estado">
<option>Dañado</option>
<option>Funcionando</option>
</select>
</div>
</td>
</tr>
<tr>
<td>
<div>
<label for="mantenimiento">Mantenimiento a realizar:
</label>
<select name="mantenimiento" id="mantenimiento">
<option>Preventivo</option>
<option>Correctivo</option>
</select>
</div>
</td>
</tr>
<tr>
<td>
<div align="center">
<input type="submit" name="registrar" id="registrar" value="Registrar" />
</div>
</td>
</tr>
</table>
</body>
</html>
Votos: 2 -
Respuestas: 2 -
Vistas: 16
Compartir en: Google
Facebook
Twitter
LinkedIn
Link
Respuestas:
-
Fecha: 18-09-2016 17:00:17 hola
Para que sea mas entendible el codigo, en tu pregunta, coloca los codigos entre los tags HTML o PHP segundo corresponda que están en la botonera .
En principio esta mal la confección del formulario por ejmplo linea
<form id="equipos" name="equipos" method="post" action="jairoscript.php"> </form>
El formulario comienza en <form id="equipos" name="equipos" method="post" action="jairoscript.php">
luego siguen todos los campos de formulario y al finalizar el formulario se termina con </form>
Revisando por arriba
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>InterConnect</title> </head> <body> <div align="center">InterConnect s.a.s </div> <table height="116" align="center"> <tr> <td height="21"> <form id="equipos" name="equipos" method="post" action="jairoscript.php"> </td> <tr> <td> <div> <label for="referencia">Referencia del equipo: </label> <input type="text" name="referencia" id="referencia" /> </div> </td> </tr> <tr> <td> <div> <label for="estado">Estado del equipo: </label> <select name="estado" id="estado"> <option value="Dañado">Dañado</option> <option value="Funcionando">Funcionando</option> </select> </div> </td> </tr> <tr> <td> <div> <label for="mantenimiento">Mantenimiento a realizar: </label> <select name="mantenimiento" id="mantenimiento"> <option value="Preventivo">Preventivo</option> <option value="Correctivo">Correctivo</option> </select> </div> </td> </tr> <tr> <td> <div align="center"> <input type="submit" name="registrar" id="registrar" value="Registrar" /> </div> </td> </tr> </table> </form> </body> </html>
y en jairoscript.php para verificar que llegan los datos
<?php print_r($_POST);
Te dejo un link sobre Formularios por si lo necesitas para saber sobre ellos. Formularios básicos
Saludos Votos: 4 - Link respuesta -
Fecha: 22-09-2016 14:45:31 Hola Jairo Buitrago
Queria saber si has leído mi respuesta y si ta ha servido.
Cuentanos que ha sucedido así estamos enterados de la situacion.
Saludos Votos: 1 - Link respuesta
Para participar activamente de la comunidad primero debes autenticarte, ingresa al sistema.Iniciar Sesión
