
obtener valor de un select en php
Publicado por Yept (1 intervención) el 24/09/2017 00:47:19
Buenas gente soy nuevo en este mundo del PHP tengo este pequeño ejemplo sobre un carrito de compras a medio hacer todavia no tengo mucho codigo pero lo que quiero saber es por que me manda un error al querer saber el valor del elemento seleccionado del select me dice:
Notice: Undefined index: mi_select in C:\Program Files (x86)\EasyPHP-5.3.5.0\www\unidad4\ejemplo8\productos.php on line 41
Notice: Undefined index: mi_select in C:\Program Files (x86)\EasyPHP-5.3.5.0\www\unidad4\ejemplo8\productos.php on line 41
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
<?php
session_start();
?>
<!doctype html>
<html lang="es">
<head>
<title>Ejemplo 6</title>
<meta charset="utf-8">
<style type="text/css">
.container{
width: 500px;
margin: 50px auto;
}
</style>
</head>
<body>
<div class="container">
<h1 style="text-align:center;">Agregar Producto</h1>
<form name="frmAgregar" method="post" action="productos.php">
<div><SELECT id="mi_select">
<OPTION value="0">WOW</OPTION>
<OPTION value="1">DOTA</OPTION>
<OPTION value="2">HOST</OPTION>
<OPTION value="3">HEART</OPTION>
</SELECT></div>
<div>Cantidad: <input type="number" name="txtCantidad" size="20"></div>
<div style="margin:15px 0px 0px 150px;">
<input type="submit" name="btnAgregar" value="Enviar">
</div>
<div><a href="mostrar.php">Mostrar produtos en carrito</a></div>
</form>
</div>
<?php
if (!isset($_POST["btnAgregar"])) {
$_SESSION["carrito"]=array();
echo "estas aqui";
}
if (isset($_POST["btnAgregar"])) {
$producto=$_REQUEST['mi_select'];
echo "estas aca";
}
?>
</body>
</html>
Valora esta pregunta


0