Error al insertar datos
Publicado por Jose (4 intervenciones) el 16/08/2017 20:55:17
Buen día, tengo problemas con un insert en mi base de datos, cabe mencionar que soy nuevo en esto, y por eso pido su ayuda.
El problema es que tengo un formulario para una base de datos en la cual me ingresa un numero de serie en una tabla. Hasta aquí, todo bien, solo que al insertar datos a la segunda tabla relacionada me tira el error de insertar datos y no entiendo por que.
Primer formulario:
Conexión e insert
Segundo Formulario
Segunda Conexion e Insert
De ante mano gracias.
El problema es que tengo un formulario para una base de datos en la cual me ingresa un numero de serie en una tabla. Hasta aquí, todo bien, solo que al insertar datos a la segunda tabla relacionada me tira el error de insertar datos y no entiendo por que.
Primer formulario:
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
26
27
<!DOCTYPE>
<html>
<head>
<title> Index</title>
</head>
<body>
<div style="text-align:center;">
</br>
<form action="Registro_nuevo.php" method="post" name="form">
<table border="1" cellpadding="1" cellspacing="0" width="450">
<form>
<h1> Ingrese No. Serie<h1>
<input type="text" name="txtnombre" max-length="13" placeholder="Ingese numero de serie"/>
<input type="submit" value="Enviar" />
</div>
</form>
</form>
</body>
</html>
<?php
include ("index_buscar.php");
?>
Conexión e insert
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
26
27
28
29
30
31
32
33
34
35
<!DOCTYPE>
<html>
<head>
<title>Registro</title>
</head>
<body>
<?php
$server = "localhost";
$usuario = "root";
$contraseña ="";
$bd= "dispensadora";
$conexion = mysqli_connect($server,$usuario,$contraseña,$bd)
or die ("Error en la conexion");
$clave = $_POST['txtserie'];
$insertar = "INSERT into coas (Etiqueta) VALUES ('$clave')";
$resultado = mysqli_query($conexion,$insertar)
or die ("Error al insertar los registros");
mysqli_close($conexion);
echo "Datos insertados correctamente";
?>
</body>
</html>
</br>
<html>
<head>
<a href="formulario.php">Back to Index</a>
</head>
<body>
</html>
Segundo Formulario
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
26
27
28
29
<!DOCTYPE>
<html>
<head>
<title> Index</title>
<link rel="stylesheet" href="index_css.css"/>
</head>
<body>
<div style="text-align:center;">
</br>
<form action="Registro_nuevo2.php" method="post" name="form">
<table border="1" cellpadding="1" cellspacing="0" width="450">
<form>
<h1> Ingrese No. Etiqueta<h1>
<input type="text" name="txtserie" max-length="13" placeholder="Ingese numero de Etiqueta"/>
<input type="submit" value="Enviar" />
</div>
</form>
</form>
</body>
</html>
<?php
include ("index_buscar.php");
?>
Segunda Conexion e Insert
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
26
27
28
29
30
31
32
33
34
35
<!DOCTYPE>
<html>
<head>
<title>Registro</title>
</head>
<body>
<?php
$server = "localhost";
$usuario = "root";
$contraseña ="";
$bd= "dispensadora";
$conexion = mysqli_connect($server,$usuario,$contraseña,$bd)
or die ("Error en la conexion");
$serietxt = $_POST['txtserie'];
$insertar = " INSERT INTO series (Serie) VALUES ('$serietxt')";
$resultado = mysqli_query($conexion,$insertar)
or die ("Error al insertar los registros");
mysqli_close($conexion);
echo "Datos insertados correctamente";
?>
</body>
</html>
</br>
<html>
<head>
<a href="formulario.php">Back to Index</a>
</head>
<body>
</html>
De ante mano gracias.
- basededatos.zip(16,5 KB)
Valora esta pregunta
0