No registra datos de formulario a base de datos con php URGENTE
Publicado por Erik (1 intervención) el 08/04/2020 23:32:47
A continuacion muestro el codigo de conexion.php.
Al momento de ingresar los datos al formulario, no los ingresa a la base de datos y aparece en pantalla el mensaje "hubo algun error"
Y aqui muestro el codigo del formulario.
Al momento de ingresar los datos al formulario, no los ingresa a la base de datos y aparece en pantalla el mensaje "hubo algun error"
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
36
37
38
39
<?php
$conectar=@mysqli_connect('localhost','id13206274_bddedufinder','Kemonito_1234');
if(!$conectar){
echo"No se puede conectar con el servidor";
}else{
$base=mysqli_select_db ($conectar, 'id13206274_edu_finder' );
if (!$base){
echo"No se encontro la base de datos";
}
}
$nombre = $_POST['nombre'];
$apellido = $_POST['apellidos'];
$municipio = $_POST['municipio'];
$edad = $_POST['edad'];
$correo = $_POST['correo'];
$sql = "INSERT INTO registro VALUES('','$nombre','$apellido','$municipio','$edad','$correo')";
$ejecutar=mysqli_query($conectar, $sql);
//$insertar=mysqli_query("INSERT INTO usuario VALUES('','$nombre','$apellidos','$municipio','$edad','$correo')",$conectar);
if(!$ejecutar){
echo"Hubo algun error";
}
else{
echo"Datos guardados correctamente <br> <a href='PAGINAINICIO.html'>volver</a>";
}
?>
Y aqui muestro el codigo del 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="es" xml:lang="es">
<style>
body{
background-image: url("fondoprueba1.jpg");
background-position: center center;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
padding-left: 50px;
padding-right: 50px;
}
</style>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Registrarse.</title>
</head>
<body background="fondoprueba1.jpg" cover;>
<center>
<br/><br/><br/><br/>
<h3>Registrate.</h3>
<!--enctype="multipart/form-data"-->
<form action="conexion.php" method="post" >
<fieldset>
<legend> <center>Datos personales</center></legend>
Nombre <br/>
<input type="text" name="nombre" value="" size="20" maxlength="30"/>
<br/>
Apellidos <br/>
<input type="text" name="apellidos" value="" size="50" maxlength="80"/>
<br/>
<label for="municipio">Municipio</label><br/>
<select id="municipio" name="municipio">
<option value="" selected="selected">- seleccionar - </option>
<option>Atizapan de Zaragoza</option>
<option>Azcapotzalco</option>
<option>Cuautitlan Izcalli</option>
<option>Gustavo A. Madero</option>
<option>Naucalpan</option>
<option>Nicolas Romero</option>
<option>Tlalnepantla de Baz</option>
<option>Vallejo</option>
</select>
<br/><br/>
<label for="edad"> Edad</label><br/>
<input type="text" size="3" maxlength="2" id="edad" name="edad"/>
<br/><br/>
Correo electronico<br/>
<input type="email" name="correo" value="" size="50" maxlength="80"/>
<br/><br/><br/>
<input type="submit" name="enviar" value="Guardar cambios" />
<input type="reset" name="limpiar" value="Borrar los datos introducidos" />
</fieldset>
</form>
</center>
</body>
</html>
Valora esta pregunta


0