PHP - no lee el post

 
Vista:
sin imagen de perfil

no lee el post

Publicado por mario (31 intervenciones) el 09/02/2016 07:06:02
hola que tal, lo que pasa es que quiero hacer doble consulta, pero al querer enviar el formulario numero, nombre, materia, salon, que es la segunda consulta no me lo envia a la base, no esta leyendo mis variables despues de dar click en el primer boton. solo me esta leyendo las variables de dias y horarios. alguna solucion ?

nota: tengo dos submit.

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
<html>
<head></head>
 
 
 <h2>Llenar formulario</h2>
<form method="post">
 
<label for="numero">Numero de maestro: <span></span></label>
      <input type="text" name="numero"   value="<?php if(isset($_POST["numero"])) echo $_POST["numero"] ; ?>" /><br/><br/>
 
<label for="nombre">Nombre del maestro: <span></span></label>
 <input type="text" name="nombre" id="nombre" value="<?php if(isset($_POST["nombre"])) echo $_POST["nombre"] ; ?>" /><br/><br/>
 
 <label for="materia">Materia: <span></span></label>
 <input type="text" name="materia" id="materia" value="<?php if(isset($_POST["materia"])) echo $_POST["materia"] ; ?>" /><br/><br/>
 
  <label for="materia">Salon: <span></span></label>
 <input type="text" name="salon" id="salon" value="<?php if(isset($_POST["salon"])) echo $_POST["salon"] ; ?>" /><br/><br/>
 
 <label>Dias que impartira clases:</label>
 
<select required='required' name="Numero">
 <option selected disabled value="" >Seleccione</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select>
 
<input type="submit" name="alta" value="enviar"/><br/>
 
</form>
 
 
<?php
 
 
error_reporting (E_ALL ^ E_DEPRECATED);
 
$conexion = mysql_connect("localhost", "root", "");
 
if (!$conexion) {
    echo "No pudo conectarse a la BD: " . mysql_error();
    exit;
}
 
if (!mysql_select_db("uacj")) {
    echo "No ha sido posible seleccionar la BD: " . mysql_error();
    exit;
}
 
 
 
if(isset($_POST['alta'])){
 
   for($i=1; $i<=$_POST['Numero']; $i++)
   {
 
 
 echo "<form method='post'>";
 
 echo "<label>Dia $i: </label><select required='required' name='hola_$i'>
<option selected disabled value='' >Seleccione</option> 
<option value='lunes'>lunes</option> 
<option value='martes'>martes</option>
<option value='miercoles'>miercoles</option>
<option value='jueves'>jueves</option>
<option value='viernes'>viernes</option> 
<option value='sabado'>sabado</option>
</select>";
 
echo "<label> Horario $i: </label><input type='time'  required='required' name='ho_$i' value='24:00:00' min='00:00:00' max='24:00:00' step='1' ><br/><br/>";
 
 
   }
   echo "<input type='submit' name='submit2' value='enviar2'/>";
 
   echo "</form>";
}
?>
 
 
 
 
<?php
if (isset($_POST['submit2'])){
 
	 $num = $_POST['numero'];
	$nomb = $_POST['nombre'];
    $materia = $_POST['materia'];
	$salon = $_POST['salon'];
 
$boton= $_POST['submit2'];
 
if (isset($_POST['hola_1'])) {
$variable1 = $_POST['hola_1'];
} else {
$variable1 = "sin clase";
}
 
if (isset($_POST['hola_2'])) {
$variable2 = $_POST['hola_2'];
} else {
$variable2 = "sin clase";
}
 
if (isset($_POST['hola_3'])) {
$variable3 = $_POST['hola_3'];
} else {
$variable3 =  "sin clase";
}
 
if (isset($_POST['hola_4'])) {
$variable4 = $_POST['hola_4'];
} else {
$variable4 = "sin clase";
}
 
if (isset($_POST['hola_5'])) {
$variable5 = $_POST['hola_5'];
} else {
$variable5 = "sin clase";
}
 
if (isset($_POST['hola_6'])) {
$variable6 = $_POST['hola_6'];
} else {
$variable6 =  "sin clase";
}
 
//////
 
if (isset($_POST['ho_1'])) {
$variabl1 = $_POST['ho_1'];
} else {
$variabl1 = "";
}
 
if (isset($_POST['ho_2'])) {
$variabl2 = $_POST['ho_2'];
} else {
$variabl2 = "sin clase";
}
 
if (isset($_POST['ho_3'])) {
$variabl3 = $_POST['ho_3'];
} else {
$variabl3 =  "sin clase";
}
 
if (isset($_POST['ho_4'])) {
$variabl4 = $_POST['ho_4'];
} else {
$variabl4 = "sin clase";
}
 
if (isset($_POST['ho_5'])) {
$variabl5 = $_POST['ho_5'];
} else {
$variabl5 =  "sin clase";
}
 
if (isset($_POST['ho_6'])) {
$variabl6 = $_POST['ho_6'];
} else {
$variabl6 = "sin clase";
}
 
 
if($boton == "enviar2")
{
 
 
 
$insertar = "INSERT INTO datos (dia1 ,hora1 ,dia2 ,hora2, dia3, hora3, dia4, hora4, dia5, hora5, dia6,hora6) VALUES ('$variable1','$variabl1','$variable2','$variabl2','$variable3','$variabl3','$variable4','$variabl4','$variable5','$variabl5','$variable6','$variabl6') ";
 
$insertar2 = " insert into datos2 (numero,nombre,materia,salon) values ('$num', '$nomb', '$materia', '$salon')";
 
$cone = mysql_query($insertar,$conexion);
 
$cone2 = mysql_query($insertar2,$conexion);
 
 echo "<script> alert('se enviaron correctamente');</script>";
 
}
 
}
 
 
?>
 
</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 Junior Suarez

no lee el post

Publicado por Junior Suarez (12 intervenciones) el 10/02/2016 15:41:29
Saludos Mario,

Analicé un poco tu post, y me di cuenta de que te estas complicando mucho.
Por ejemplo: Si guardas los datos al pulsar el segundo submit de segundo formulario, no hay necesidad de ocultarlo, muestra ese pequeño formulario desde el principio.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
sin imagen de perfil

no lee el post

Publicado por mario (31 intervenciones) el 10/02/2016 19:40:09
es cierto bro ese era el problema muchisimas gracias.
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