PHP - Codigo que inserta 5 registros sin explicacion

 
Vista:
sin imagen de perfil

Codigo que inserta 5 registros sin explicacion

Publicado por Daniel (13 intervenciones) el 20/09/2017 15:59:04
Buenas,

Tengo un codigo php que inserta 5 registros a la vez cuando modifico cualquiera de los que estan ya en la base de datos, me explico: tengo una aplicacion que tiene una parte para modificar ciertos datos de una base de datos, y cuando se busca un registro, aparece todo correcto pero al modificarlo inserta 5 registros (la consulta no da ningun error y el codigo php tampoco, esta todo correcto, pero no tiene que insertar 5 registros iguales, solo modificar el que se modifica en la aplicacion web). Alguna idea de porque pasa esto?

Os dejo el codigo:

El primer archivo que junta los dos siguientes: (los otros dos los posteo abajo, que no me deja por el limite de caracteres)

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
70
71
72
73
74
<html>
 
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>
		<?PHP
			session_start();
			$proyectoseleccionado = $_SESSION['proyectoseleccionado'];
			print("$proyectoseleccionado");
		?>
	</title>
	<link href="estilos/style.css" rel="stylesheet" type="text/css" media="screen"/>
</head>
 
 
<body>
<div id="todo">
 
		<div id="sesion">
			<div id="proyecto">
				<center>
				<?PHP
				session_start();
				$proyectoseleccionado = $_SESSION['proyectoseleccionado'];
				print("$proyectoseleccionado - Modificar telefonos e IPAD");
				?>
				</center>
			</div>
			<div id="nombrelog" align="center">
				<?PHP
				error_reporting(E_ALL ^ E_NOTICE);
				session_start();
				$nombre = $_SESSION['nombre'];
				print("Bienvenido, $nombre");
				?>
				<div id="botondeslog">
				<?PHP
						if (isset($_REQUEST['Desconectar'])){
 
						unset($_SESSION['nombre']);
						print ("Desconectado");
						session_destroy();
						header ("Location: login.php");
 
						}
				?>
				<form action="principal.php"><input type="submit" value="Desconectar" name="Desconectar" class="deslog"></form>
				</div>
			</div>
 
		</div>
 
<div id='divdepruebaizquierda'>
<center><h1>Telefonos</h1></center>
	<?PHP
 
	include ("modificartelefonos.php");
 
	?>
 
</div>
 
<div id='divdepruebaderecha'>
<center><h1>Ipad</h1></center>
	<?PHP
 
	include ("modificaripad.php");
 
	?>
</div>
 
</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
sin imagen de perfil

Codigo que inserta 5 registros sin explicacion

Publicado por Daniel (13 intervenciones) el 20/09/2017 16:15:53
Modificartelefonos.php

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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<html>
 
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>
		<?PHP
			session_start();
			$proyectoseleccionado = $_SESSION['proyectoseleccionado'];
			print("$proyectoseleccionado");
		?>
	</title>
	<link href="estilos/style.css" rel="stylesheet" type="text/css" media="screen"/>
</head>
 
<body>
<div id="todo">
 
 
		<div id="contenido">
 
				<div id="modtelatpmc">
				<center>
 
					<?PHP
					//Buscar el numero de delegado relacionado con la info que queremos
						if (isset($_REQUEST['buscar'])){
 
							include ("inc/db.php");
 
							$numero_delegado = $_REQUEST['numero_delegado'];
 
							//instrucción
							$sql = "select * from telefonos where numero_delegado='$numero_delegado' and proyecto='$proyectoseleccionado'";
							$result= mysqli_query($conn, $sql);
 
							// mostrar
							if (mysqli_num_rows($result) > 0){
 
							$row=mysqli_fetch_assoc($result);
 
							$numero_delegado=$row['numero_delegado'];
							$nombred=$row['nombre'];
							$numero_largo = $row['numero_largo'];
							$numero_corto = $row['numero_corto'];
							$PIN = $row['PIN'];
							$PUK = $row['PUK'];
							$IMEI = $row['IMEI'];
							$caja = $row['caja'];
							$adaptador = $row['adaptador'];
							$cable = $row['cable'];
							$auriculares = $row['auriculares'];
							$disponible = $row['disponible'];
							$proyecto = $row['proyecto'];
							$fecha_entrega = $row['fecha_entrega'];
							$fecha_devolucion = $row['fecha_devolucion'];
							$robado = $row['robado'];
							$observaciones = $row['observaciones'];
 
 
							echo 	"<form action='telipad.php'>";
							echo	"<center><table>";
							echo		"<tr>";
							echo		"<td>Numero de delegado:</td><td><input type='text' value='$numero_delegado' name='numero_delegado' placeholder='$numero_delegado' ></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>Nombre:</td><td><input type='text' value='$nombred' name='nombre' placeholder='$nombred' ></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>Numero largo:</td><td><input type='text' value='$numero_largo' name='numero_largo' placeholder='$numero_largo' ></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>Numero corto:</td><td><input type='text' name='numero_corto' value='$numero_corto' placeholder='$numero_corto' ></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>PIN:</td><td><input type='text' name='PIN' value='$PIN' placeholder='$PIN' ></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>PUK:</td><td><input type='text' name='PUK' value='$PUK' placeholder='$PUK' ></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>IMEI:</td><td><input type='text' name='IMEI' value='$IMEI' placeholder='$IMEI' ></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>Caja:</td><td><select name='caja' value='$caja' ><option value='seleccionar'>Seleccionar</option><option value='SI' >SI</option><option value='SI no original' >SI no original</option><option value='NO'>NO</option></select></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>Adaptador:</td><td><select name='adaptador' value='$adaptador' ><option value='seleccionar'>Seleccionar</option><option value='SI' >SI</option><option value='SI no original' >SI no original</option><option value='NO'>NO</option></select></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>Cable:</td><td><select name='cable' value='$cable' ><option value='seleccionar'>Seleccionar</option><option value='SI' >SI</option><option value='SI no original' >SI no original</option><option value='NO'>NO</option></select></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>Auriculares:</td><td><select name='auriculares' value='$auriculares' ><option value='seleccionar'>Seleccionar</option><option value='SI' >SI</option><option value='SI no original' >SI no original</option><option value='NO'>NO</option></select></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>Disponible:</td><td><select name='disponible' value='$disponible' ><option value='seleccionar'>Seleccionar</option><option value='SI'>SI</option><option value='NO'>NO</option></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>Proyecto:</td><td><input type='text' name='proyecto' value='$proyecto' placeholder='$proyecto' ></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>Fecha de entrega:</td><td><input type='date' name='fecha_entrega' value='$fecha_entrega' placeholder='$fecha_entrega'></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>Fecha de devolucion:</td><td><input type='date' name='fecha_devolucion' value='$fecha_devolucion' placeholder='$fecha_devolucion'></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>Robado:</td><td><select name='robado' value='$robado' ><option value='seleccionar'>Seleccionar</option><option value='SI'>SI</option><option value='NO'>NO</option></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>Observaciones:</td><td><textarea name='observaciones' rows='4' cols='20'>$observaciones</textarea></td>";
							echo		"</tr>";
 
							echo	"</table></center>";
							echo	"<br><br>";
							echo	"<center><input type='submit' value='Modificar Telefono' name='modificartel'></center>";
							echo	"</form>";
 
							echo	"<br><br><br>";
 
							}
							else {
									echo "No coincide";
							}
 
 
							mysqli_close($conn);
						}
 
						//Actualizar la info en la bbdd
						if (isset($_REQUEST['modificartel'])){
 
							include ("inc/db.php");
 
							$numero_delegado=$_REQUEST['numero_delegado'];
							$nombredc=$_REQUEST['nombre'];
							$Numero_largoc = $_REQUEST['numero_largo'];
							$Numero_cortoc = $_REQUEST['numero_corto'];
							$PINc = $_REQUEST['PIN'];
							$PUKc = $_REQUEST['PUK'];
							$IMEIc = $_REQUEST['IMEI'];
							$cajac = $_REQUEST['caja'];
							$adaptadorc = $_REQUEST['adaptador'];
							$cablec = $_REQUEST['cable'];
							$auricularesc = $_REQUEST['auriculares'];
							$disponiblec = $_REQUEST['disponible'];
							$Proyectoc = $_REQUEST['proyecto'];
							$Fecha_entregac = $_REQUEST['fecha_entrega'];
							$Fecha_devolucionc = $_REQUEST['fecha_devolucion'];
							$Robadoc = $_REQUEST['robado'];
							$Observacionesc = $_REQUEST['observaciones'];
 
							$sql = "update telefonos set numero_delegado='$numero_delegado', nombre='$nombredc', numero_largo='$Numero_largoc', numero_corto='$Numero_cortoc', PIN='$PINc', PUK='$PUKc', IMEI='$IMEIc', caja='$cajac', adaptador='$adaptadorc', cable='$cablec', auriculares='$auricularesc', disponible='$disponiblec', proyecto='$Proyectoc', fecha_entrega='$Fecha_entregac', fecha_devolucion='$Fecha_devolucionc', robado='$Robadoc', observaciones='$Observacionesc' where numero_delegado='$numero_delegado' and proyecto='$proyectoseleccionado'";
 
							if (mysqli_query($conn, $sql)){
								echo "Se han modificado los datos con exito <br><br><br>";
							}
							else
								echo "Error en el registro de modificación".mysql_error($conn);
							mysqli_close($conn);
						}
						?>
 
						<?PHP
						if (isset($_REQUEST['anadirtel'])){
 
							include ("inc/db.php");
 
							$nnumero_delegado=$_REQUEST['nuevonumero_delegado'];
							$nnombred=$_REQUEST['nuevonombre'];
							$nnumero_largo = $_REQUEST['nuevonumero_largo'];
							$nnumero_corto = $_REQUEST['nuevonumero_corto'];
							$nPIN = $_REQUEST['nuevoPIN'];
							$nPUK = $_REQUEST['nuevoPUK'];
							$nIMEI = $_REQUEST['nuevoIMEI'];
							$ncaja = $_REQUEST['nuevocaja'];
							$nadaptador = $_REQUEST['nuevoadaptador'];
							$ncable = $_REQUEST['nuevocable'];
							$nauriculares = $_REQUEST['nuevoauriculares'];
							$ndisponible = $_REQUEST['nuevodisponible'];
							$nProyecto = $_REQUEST['nuevoproyecto'];
							$nFecha_entrega = $_REQUEST['nuevofecha_entrega'];
							$nFecha_devolucion = $_REQUEST['nuevofecha_devolucion'];
							$nRobado = $_REQUEST['nuevorobado'];
 
 
							$sql = "insert into telefonos (numero_delegado,nombre,numero_largo,numero_corto,PIN,PUK,IMEI,caja,adaptador,cable,auriculares,disponible,proyecto,fecha_entrega,fecha_devolucion,robado) values
								   ('$nnumero_delegado', '$nnombred', '$nnumero_largo', '$nnumero_corto', '$nPIN', '$nPUK', '$nIMEI', '$ncaja', '$nadaptador', '$ncable', '$nauriculares', '$ndisponible', '$nProyecto', '$nFecha_entrega', '$nFecha_devolucion', '$nRobado')";
 
 
							if (mysqli_query($conn, $sql)){
								echo "Telefono añadido correctamente <br><br><br>";
								}
							else
								echo "Error".mysql_error($conn);
 
							mysqli_close($conn);
						}
 
 
					?>
 
					<form action="telipad.php">
						<center><table>
							<tr>
							<td>Numero de delegado:</td><td><input type="text" name="numero_delegado"><td></td>
							</tr>
						</table></center>
							<br><br>
							<center><input type="submit" value="Buscar" name="buscar"></center>
					</form>
 
					<br>
					<center><a href='principal.php'>Volver</a>&nbsp; - &nbsp; <a href='imprimirtelipad.php'>Imprimir</a> </center>
 
					<hr>
 
					<br>
					<form action="telipad.php">
					<center><h3>Añadir</h3></center>
					<center><table>
					<tr>
					<td>Numero de delegado</td><td><select placeholder="Numero de delegado" name="nuevonumero_delegado">
					<option value='seleccionar'>Seleccionar</option>
					<?PHP
 
						include ("inc/db.php");
 
						// instrucción
						$sql = "select numero_delegado from delegados where proyecto='$proyectoseleccionado'";
						$result= mysqli_query($conn, $sql);
 
						// mostrar
 
						if (mysqli_num_rows($result) > 0){
 
							for($i="0";$i<num_rows;$i++);
							$num_rows=mysqli_num_rows($result);
 
							while($row = mysqli_fetch_assoc($result)){
							echo ("<option value='". $row['numero_delegado'] ."'>". $row['numero_delegado'] ."</option>");
							}
							mysqli_close($conn);
 
						}
 
					?></td></select>
					</tr>
					<tr>
					<td>Nombre</td><td><input type="text" placeholder="Nombre" name="nuevonombre"></td>
					</tr>
					<tr>
					<td>Numero largo</td><td><input type="text" placeholder="Numero largo" name="nuevonumero_largo"></td>
					</tr>
					<tr>
					<td>Numero corto</td><td><input type="text" placeholder="Numero corto" name="nuevonumero_corto"></td>
					</tr>
					<tr>
					<td>PIN</td><td><input type="text" placeholder="PIN" name="nuevoPIN"></td>
					</tr>
					<tr>
					<td>PUK</td><td><input type="text" placeholder="PUK" name="nuevoPUK"></td>
					</tr>
					<tr>
					<td>IMEI</td><td><input type="text" placeholder="IMEI" name="nuevoIMEI"></td>
					</tr>
					</tr>
					<tr>
					<td>Caja:</td><td><select name='nuevocaja' ><option value='seleccionar'>Seleccionar</option><option value='SI' >SI</option><option value='SI no original' >SI no original</option><option value='NO'>NO</option></select></td>
					</tr>
					<tr>
					<td>Adaptador:</td><td><select name='nuevoadaptador'  ><option value='seleccionar'>Seleccionar</option><option value='SI' >SI</option><option value='SI no original' >SI no original</option><option value='NO'>NO</option></select></td>
					</tr>
					<tr>
					<td>Cable:</td><td><select name='nuevocable' ><option value='seleccionar'>Seleccionar</option><option value='SI' >SI</option><option value='SI no original' >SI no original</option><option value='NO'>NO</option></select></td>
					</tr>
					<tr>
					<td>Auriculares:</td><td><select name='nuevoauriculares' ><option value='seleccionar'>Seleccionar</option><option value='SI' >SI</option><option value='SI no original' >SI no original</option><option value='NO'>NO</option></select></td>
					</tr>
					<tr>
					<td>Disponible</td><td><select name='nuevodisponible' placeholder="Disponible?" ><option value='seleccionar'>Seleccionar</option><option value='SI'>SI</option><option value='NO'>NO</option></select>
					</td>
					</tr>
					<tr>
					<td>Proyecto</td><td><select  name='nuevoproyecto' >
					<?PHP
 
						include ("inc/db.php");
 
						// instrucción
						$sql = "select nombre from proyectos";
						$result= mysqli_query($conn, $sql);
 
						// mostrar
 
						if (mysqli_num_rows($result) > 0){
 
							for($i="0";$i<num_rows;$i++);
							$num_rows=mysqli_num_rows($result);
 
							while($row = mysqli_fetch_assoc($result)){
							echo ("<option value='". $row['nombre'] ."'>". $row['nombre'] ."</option>");
							}
							mysqli_close($conn);
 
						}
 
					?></select></td>
					</tr>
					<tr>
					<td>Fecha de entrega</td><td><input type="date" name="nuevofecha_entrega"></td>
					</tr>
					<tr>
					<td>Fecha de devolucion</td><td><input type="date" name="nuevofecha_devolucion"></td>
					</tr>
					<tr>
					<td>Robado:</td><td><select name='nuevorobado'  ><option value='seleccionar'>Seleccionar</option><option value='SI'>SI</option><option value='NO'>NO</option></select></td>
					</tr>
					</table><br><br>
					<input type="submit" value="Añadir Telefono" name="anadirtel">
					</center>
					</form>
 
					</center>
					</div>
 
					<br>
					<center><a href='principal.php'>Volver</a></center>
		</div>
</div>
 
</body>
 
</html>
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
sin imagen de perfil

Codigo que inserta 5 registros sin explicacion

Publicado por Daniel (13 intervenciones) el 20/09/2017 16:17:01
Modificaripad.php

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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
<html>
 
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>
		<?PHP
			session_start();
			$proyectoseleccionado = $_SESSION['proyectoseleccionado'];
			print("$proyectoseleccionado");
		?>
	</title>
	<link href="estilos/style.css" rel="stylesheet" type="text/css" media="screen"/>
</head>
 
<body>
<div id="todo">
 
		<div id="contenido">
 
				<div id="modipadatpmc">
				<center>
 
					<?PHP
					//Actualizar la info en la bbdd
						if (isset($_REQUEST['modificaripad'])){
 
							include ("inc/db.php");
 
							$numero_delegado=$_REQUEST['numero_delegado'];
							$nombredc=$_REQUEST['nombre'];
							$Numero_largoc = $_REQUEST['numero_largo'];
							$Numero_cortoc = $_REQUEST['numero_corto'];
							$Trackerc = $_REQUEST['tracker'];
							$PINc = $_REQUEST['PIN'];
							$PUKc = $_REQUEST['PUK'];
							$IMEIc = $_REQUEST['IMEI'];
							$cajac = $_REQUEST['caja'];
							$adaptadorc = $_REQUEST['adaptador'];
							$cablec = $_REQUEST['cable'];
							$disponiblec = $_REQUEST['disponible'];
							$Proyectoc = $_REQUEST['proyecto'];
							$Fecha_entregac = $_REQUEST['fecha_entrega'];
							$Fecha_devolucionc = $_REQUEST['fecha_devolucion'];
							$Robadoc = $_REQUEST['robado'];
							$Observacionesc = $_REQUEST['observaciones'];
 
							$sql = "update ipad set numero_delegado='$numero_delegado', nombre='$nombredc', numero_largo='$Numero_largoc', tracker='$Trackerc', numero_corto='$Numero_cortoc', PIN='$PINc', PUK='$PUKc', IMEI='$IMEIc', caja='$cajac', adaptador='$adaptadorc', cable='$cablec', disponible='$disponiblec', proyecto='$Proyectoc', fecha_entrega='$Fecha_entregac', fecha_devolucion='$Fecha_devolucionc', robado='$Robadoc', observaciones='$Observacionesc'  where nombre='$nombredc';";
 
							if (mysqli_query($conn, $sql)){
								echo "Se han modificado los datos con exito <br><br><br>";
							}
							else
								echo "Error en el registro de modificación".mysql_error($conn);
							mysqli_close($conn);
						}
 
					//Buscar el numero de delegado relacionado con la info que queremos
						if (isset($_REQUEST['buscar'])){
							$numero_delegado = $_REQUEST['numero_delegado'];
							include ("inc/db.php");
 
							//instrucción
							$sql = "select * from ipad where numero_delegado='$numero_delegado' and proyecto='$proyectoseleccionado'";
							$result= mysqli_query($conn, $sql);
 
							// mostrar
							if (mysqli_num_rows($result) > 0){
 
							$row=mysqli_fetch_assoc($result);
 
							$numero_delegado=$row['numero_delegado'];
							$nombred=$row['nombre'];
							$numero_largo = $row['numero_largo'];
							$numero_corto = $row['numero_corto'];
							$tracker = $row['tracker'];
							$PIN = $row['PIN'];
							$PUK = $row['PUK'];
							$IMEI = $row['IMEI'];
							$caja = $row['caja'];
							$adaptador = $row['adaptador'];
							$cable = $row['cable'];
							$disponible = $row['disponible'];
							$proyecto = $row['proyecto'];
							$fecha_entrega = $row['fecha_entrega'];
							$fecha_devolucion = $row['fecha_devolucion'];
							$robado = $row['robado'];
							$observaciones = $row['observaciones'];
 
 
							echo 	"<form action='telipad.php'>";
							echo	"<center><table>";
							echo		"<tr>";
							echo		"<td>Numero de delegado:</td><td><input type='text' value='$numero_delegado' name='numero_delegado' placeholder='$numero_delegado' required></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>Nombre:</td><td><input type='text' value='$nombred' name='nombre' placeholder='$nombred' required></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>Numero largo:</td><td><input type='text' value='$numero_largo' name='numero_largo' placeholder='$numero_largo' required></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>Numero corto:</td><td><input type='text' name='numero_corto' value='$numero_corto' placeholder='$numero_corto' required></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>Tracker:</td><td><input type='text' name='tracker' value='$tracker' placeholder='$tracker' required></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>PIN:</td><td><input type='text' name='PIN' value='$PIN' placeholder='$PIN' required></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>PUK:</td><td><input type='text' name='PUK' value='$PUK' placeholder='$PUK' required></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>IMEI:</td><td><input type='text' name='IMEI' value='$IMEI' placeholder='$IMEI' required></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>Caja:</td><td><select name='caja' value='$caja' required><option value='seleccionar'>Seleccionar</option><option value='SI' >SI</option><option value='SI no original' >SI no original</option><option value='NO'>NO</option></select></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>Adaptador:</td><td><select name='adaptador' value='$adaptador' required><option value='seleccionar'>Seleccionar</option><option value='SI' >SI</option><option value='SI no original' >SI no original</option><option value='NO'>NO</option></select></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>Cable:</td><td><select name='cable' value='$cable' required><option value='seleccionar'>Seleccionar</option><option value='SI' >SI</option><option value='SI no original' >SI no original</option><option value='NO'>NO</option></select></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>Disponible:</td><td><select name='disponible' value='$disponible' required><option value='seleccionar'>Seleccionar</option><option value='SI'>SI</option><option value='NO'>NO</option></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>Proyecto:</td><td><input type='text' name='proyecto' value='$proyecto' placeholder='$proyecto' required></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>Fecha de entrega:</td><td><input type='date' name='fecha_entrega' value='$fecha_entrega' placeholder='$fecha_entrega'></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>Fecha de devolucion:</td><td><input type='date' name='fecha_devolucion' value='$fecha_devolucion' placeholder='$fecha_devolucion'></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>Robado:</td><td><select name='robado' value='$robado' required><option value='seleccionar'>Seleccionar</option><option value='SI'>SI</option><option value='NO'>NO</option></td>";
							echo		"</tr>";
							echo		"<tr>";
							echo		"<td>Observaciones:</td><td><textarea name='observaciones' rows='4' cols='20'>$observaciones</textarea></td>";
							echo		"</tr>";
 
							echo	"</table></center>";
							echo	"<br><br>";
							echo	"<center><input type='submit' value='Modificar Ipad' name='modificaripad'></center>";
							echo	"</form>";
 
							echo	"<br><br><br>";
 
							}
							else {
									echo "No coincide";
							}
 
 
							mysqli_close($conn);
						}
						?>
 
						<?PHP
						if (isset($_REQUEST['anadiripad'])){
 
							include ("inc/db.php");
 
							$nnumero_delegado=$_REQUEST['nuevonumero_delegado'];
							$nnombred=$_REQUEST['nuevonombre'];
							$nnumero_largo = $_REQUEST['nuevonumero_largo'];
							$nnumero_corto = $_REQUEST['nuevonumero_corto'];
							$ntracker = $_REQUEST['nuevotracker'];
							$nPIN = $_REQUEST['nuevoPIN'];
							$nPUK = $_REQUEST['nuevoPUK'];
							$nIMEI = $_REQUEST['nuevoIMEI'];
							$ncaja = $_REQUEST['nuevocaja'];
							$nadaptador = $_REQUEST['nuevoadaptador'];
							$ncable = $_REQUEST['nuevocable'];
							$ndisponible = $_REQUEST['nuevodisponible'];
							$nProyecto = $_REQUEST['nuevoproyecto'];
							$nFecha_entrega = $_REQUEST['nuevofecha_entrega'];
							$nFecha_devolucion = $_REQUEST['nuevofecha_devolucion'];
							$nRobado = $_REQUEST['nuevorobado'];
 
							$sql = "insert into ipad (numero_delegado,nombre,numero_largo,numero_corto,tracker,PIN,PUK,IMEI,caja,adaptador,cable,disponible,proyecto,fecha_entrega,fecha_devolucion,robado) values
								   ('$nnumero_delegado', '$nnombred', '$nnumero_largo', '$nnumero_corto', '$ntracker', '$nPIN', '$nPUK', '$nIMEI', '$ncaja', '$nadaptador', '$ncable', '$ndisponible', '$nProyecto', '$nFecha_entrega', '$nFecha_devolucion', '$nRobado')";
 
 
							if (mysqli_query($conn, $sql)){
								echo "Ipad añadido correctamente <br><br><br>";
								}
							else
								echo "Error".mysql_error($conn);
 
							mysqli_close($conn);
						}
 
 
					?>
 
					<form action="telipad.php">
						<center><table>
							<tr>
							<td>Numero de delegado:</td><td><input type="text" name="numero_delegado"><td></td>
							</tr>
						</table></center>
							<br><br>
							<center><input type="submit" value="Buscar" name="buscar"></center>
					</form>
 
					<br>
					<center><a href='principal.php'>Volver</a></center>
 
					<hr>
 
					<br>
					<form action="telipad.php">
					<center><h3>Añadir</h3></center>
					<center><table>
					<tr>
					<td>Numero de delegado</td><td><select placeholder="Numero de delegado" name="nuevonumero_delegado">
					<option value='seleccionar'>Seleccionar</option>
					<?PHP
						include ("inc/db.php");
 
						// instrucción
						$sql = "select numero_delegado from delegados where proyecto='$proyectoseleccionado'";
						$result= mysqli_query($conn, $sql);
 
						// mostrar
 
						if (mysqli_num_rows($result) > 0){
 
							for($i="0";$i<num_rows;$i++);
							$num_rows=mysqli_num_rows($result);
 
							while($row = mysqli_fetch_assoc($result)){
							echo ("<option value='". $row['numero_delegado'] ."'>". $row['numero_delegado'] ."</option>");
							}
							mysqli_close($conn);
 
						}
 
					?></td></select>
					</tr>
					<tr>
					<td>Nombre</td><td><input type="text" placeholder="Nombre" name="nuevonombre"></td>
					</tr>
					<tr>
					<td>Numero largo</td><td><input type="text" placeholder="Numero largo" name="nuevonumero_largo"></td>
					</tr>
					<tr>
					<td>Numero corto</td><td><input type="text" placeholder="Numero corto" name="nuevonumero_corto"></td>
					</tr>
					<tr>
					<td>Tracker</td><td><input type="text" placeholder="Tracker" name="nuevotracker"></td>
					</tr>
					<tr>
					<td>PIN</td><td><input type="text" placeholder="PIN" name="nuevoPIN"></td>
					</tr>
					<tr>
					<td>PUK</td><td><input type="text" placeholder="PUK" name="nuevoPUK"></td>
					</tr>
					<tr>
					<td>IMEI</td><td><input type="text" placeholder="IMEI" name="nuevoIMEI"></td>
					</tr>
					</tr>
					<tr>
					<td>Caja:</td><td><select name='nuevocaja' required><option value='seleccionar'>Seleccionar</option><option value='SI' >SI</option><option value='SI no original' >SI no original</option><option value='NO'>NO</option></select></td>
					</tr>
					<tr>
					<td>Adaptador:</td><td><select name='nuevoadaptador' required><option value='seleccionar'>Seleccionar</option><option value='SI' >SI</option><option value='SI no original' >SI no original</option><option value='NO'>NO</option></select></td>
					</tr>
					<tr>
					<td>Cable:</td><td><select name='nuevocable' required><option value='seleccionar'>Seleccionar</option><option value='SI' >SI</option><option value='SI no original' >SI no original</option><option value='NO'>NO</option></select></td>
					</tr>
					<tr>
					<td>Disponible</td><td><select name='nuevodisponible' placeholder="Disponible?" required><option value='seleccionar'>Seleccionar</option><option value='SI'>SI</option><option value='NO'>NO</option></select>
					</td>
					</tr>
					<tr>
					<td>Proyecto</td><td><select  name='nuevoproyecto' required>
					<?PHP
						include ("inc/db.php");
 
						// instrucción
						$sql = "select nombre from proyectos";
						$result= mysqli_query($conn, $sql);
 
						// mostrar
 
						if (mysqli_num_rows($result) > 0){
 
							for($i="0";$i<num_rows;$i++);
							$num_rows=mysqli_num_rows($result);
 
							while($row = mysqli_fetch_assoc($result)){
							echo ("<option value='". $row['nombre'] ."'>". $row['nombre'] ."</option>");
							}
							mysqli_close($conn);
 
						}
 
					?></select></td>
					</tr>
					<tr>
					<td>Fecha de entrega</td><td><input type="date" name="nuevofecha_entrega"></td>
					</tr>
					<tr>
					<td>Fecha de devolucion</td><td><input type="date" name="nuevofecha_devolucion"></td>
					</tr>
					<tr>
					<td>Robado:</td><td><select name='nuevorobado' required ><option value='seleccionar'>Seleccionar</option><option value='SI'>SI</option><option value='NO'>NO</option></select></td>
					</tr>
					</table><br><br>
					<input type="submit" value="Añadir Ipad" name="anadiripad">
					</center>
					</form>
 
					</center>
					</div>
 
					<br>
					<center><a href='principal.php'>Volver</a></center>
		</div>
</div>
 
</body>
 
</html>
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