Bases de Datos - Ayuda con CRUD: Notice: Undefined index: id

 
Vista:
sin imagen de perfil

Ayuda con CRUD: Notice: Undefined index: id

Publicado por Nicolas (1 intervención) el 07/05/2018 05:45:29
Al cargar la pagina me sale el siguiente error: Notice: Undefined index: id in C:\xampp\htdocs\CRUD\formulario.php on line 50
la tabla se visualiza, pero no muestra los id enumerados, a que se debera el error?

Aqui el codigo:

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
66
67
68
69
<?php
$con=mysqli_connect("localhost","root","","crud") or die("Se ha presentado un error en la conexion");
 
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>CRUD</title>
</head>
<body>
<form method="POST" action="formulario.php">
	<label>Nombre:</label>
	<input type="text" name="nombre" placeholder="Escriba su nombre"><br>
	<label>Contraseña:</label>
	<input type="password" name="passw" placeholder="Escriba su contraseña"><br>
	<label>Email:</label>
	<input type="text" name="email" placeholder="Escriba su email"><br>
	<input type="submit" name="insert" value="Insertar Datos">
</form>
<?php
if(isset($_POST['insert'])){
	$usuario=$_POST['nombre'];
	$pass=$_POST['passw'];
	$email=$_POST['email'];
 
	$insertar="INSERT INTO usuarios (usuario,password,email) VALUES('$usuario','$pass','$email')";
 
	$ejecutar=mysqli_query($con, $insertar);
	if($ejecutar){
		echo "<h1>Se insertó correctamente</h1>";
	}
 
}
?>
<table width="500" border="2" style="background-color: #F9F9F9;">
	<tr>
		<th>ID</th>
		<th>Usuario</th>
		<th>Password</th>
		<th>Email</th>
		<th>Editar</th>
		<th>Borrar</th>
	</tr>
	<?php
	$consulta="SELECT * FROM usuarios";
	$ejecutar=mysqli_query($con, $consulta);
	$i=0;
	while ($fila=mysqli_fetch_array($ejecutar)) {
		$id=$fila['id'];
		$usuario=$fila['usuario'];
		$password=$fila['password'];
		$email=$fila['email'];
 
		$i++;
 
	?>
	<tr align="center">
		<td><?php echo $id; ?></td>
		<td><?php echo $usuario; ?></td>
		<td><?php echo $password; ?></td>
		<td><?php echo $email; ?></td>
		<td><a href="formulario.php?editar=<?php echo $id; ?>">Editar</a></td>
		<td><a href="formulario.php?borrar=<?php echo $id; ?>">Borrar</a></td>
	</tr>
	<?php } ?>
</table>
</body>
</html>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 93
Bronce
Ha mantenido su posición en Bases de Datos (en relación al último mes)
Gráfica de Bases de Datos

Ayuda con CRUD: Notice: Undefined index: id

Publicado por xve (107 intervenciones) el 07/05/2018 08:43:47
Hola Nicolas, por el error, entiendo que no existe el campo id en la base de datos... puede ser?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar