Select no recibo los datos al enviar el formulario
Publicado por wilmary (3 intervenciones) el 16/07/2016 05:46:14
Tengo un formulario con un select que esta cargado con datos de la base de datos, y deseo registrar este formulario a traves de registro.php.
En este select no hay problema porq me carga los datos de los cursos, el problema es q no estoy recibiendo este parametro, solo el nombre del alumno que esta en el input
Aqui adjunto el archivo registro_curso.php
En este select no hay problema porq me carga los datos de los cursos, el problema es q no estoy recibiendo este parametro, solo el nombre del alumno que esta en el input
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
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Elegir curso</title>
</head>
<body>
Lista de cursos<br />
<form name="form1" method="post" action="registro_curso.php">
<p>
<select name="codigo">
<?
$conn=mysqli_connect("localhost","root","","pppp") ;
$consulta="select * from cursos";
$resultado=mysqli_query($conn,$consulta);
while($lista=mysqli_fetch_array($resultado)){
?>
<option value="<? $lista['nombre']?> "> <? echo $lista['nombre']?></option>
<? } ?>
</select>
</p>
<p>Alumno:
<input name="alumno" type="text" id="alumno">
</p>
<input type="submit" name="Submit" value="Aceptar">
</form>
</body>
</html>
Aqui adjunto el archivo registro_curso.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?
echo $_POST[codigo];
echo $_POST[alumno];
if (isset($_POST[codigo]) && !empty($_POST[codigo]) &&
isset($_POST[alumno]) && !empty($_POST[alumno]))
{
$conn=mysqli_connect("localhost","root","","pppp") ;
mysqli_query($link, "INSERT INTO registro VALUES ('$_POST[codigo]', '$_POST[alumno]'");
mysqli_close($link);
echo 'Los datos han sido insertados en la base de datos';
echo "<br>";
echo '<input type="button" onclick=location.href="index.php" value="Aceptar">';
}else
{
echo 'Problema al insertar datos';
echo "<br>";
echo '<input type="button" onclick=location.href="index.php" value="Aceptar">';
}
?>
Valora esta pregunta


0