PHP - variable que se pierde

 
Vista:
sin imagen de perfil
Val: 557
Bronce
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

variable que se pierde

Publicado por movick (1056 intervenciones) el 03/10/2014 04:50:16
este javascript:
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
function calcularEdad()
{
    var fecha=document.getElementById("user_date").value;
 
        var values=fecha.split("/");
        var dia = values[0];
        var mes = values[1];
        var ano = values[2];
        fecha=	dia+"/"+mes	+"/"+ano;
 
    if(validate_fecha(fecha)==true)
    {
        // Si la fecha es correcta, calculamos la edad
        var values=fecha.split("/");
 
		var dia = values[0];
        var mes = values[1];
        var ano = values[2];
		alert(ano);
        // cogemos los valores actuales
        var fecha_hoy = new Date();
        var ahora_ano = fecha_hoy.getYear();
        var ahora_mes = fecha_hoy.getMonth();
        var ahora_dia = fecha_hoy.getDate();
 
        // realizamos el calculo
        var edad = (ahora_ano + 1900) - ano;
        if ( ahora_mes < (mes - 1))
        {
            edad--;
        }
        if (((mes - 1) == ahora_mes) && (ahora_dia < dia))
        {
            edad--;
        }
        if (edad > 1900)
        {
            edad -= 1900;
        }
 
        document.getElementById("result").innerHTML="Tienes "+edad+" años";
    }else{
        document.getElementById("result").innerHTML="La fecha "+fecha+" es incorrecta";
    }
}



es para pasarlo al INPUT TYPE TEXT ESTE y
estoy tratando de imprimir la variable que envio con POST, pero no lo hace con el onBlur
si alguien puede ver que pasa por favor ayudenme.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<TR>
	<td>Fecha de Nac.:</td>
    <td><input type="text" size=10 maxlength=10 name="fechanac" onBlur="calcularEdad(this);" onKeyUp="mascara(this,'-',patron,true)" id="fechanac">
 
<?php
 
 
if (isset($_POST['fechanac']) and $_POST['fechanac']!="" ){
echo $fechanac=$_POST['fechanac'];
 $dianaz= substr($fecha,0,2);
 $mesnaz= substr($fecha,3,2);
 $anonaz= substr($fecha,6,4);
}
 
?>
</td>
</TR>
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: 3.943
Oro
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

variable que se pierde

Publicado por xve (6935 intervenciones) el 03/10/2014 10:59:52
Hola Movick, no entiendo muy bien tu código...

en teoría, tienes que enviar el formulario y recargar la página para que $_POST['fechanac']; tenga valor...

No se muy bien si envías el formulario o no...
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
Val: 729
Bronce
Ha aumentado 1 puesto en PHP (en relación al último mes)
Gráfica de PHP

variable que se pierde

Publicado por Gonzalo (615 intervenciones) el 03/10/2014 15:44:32
buenos dias movick
posiblemente aqui esta el error:

POST["fechanac"], en que momento lo pasas a la variable fecha?


if (isset($_POST['fechanac']) and $_POST['fechanac']!="" )
{
echo $fechanac=$_POST['fechanac']; // pasas el post a fechanac

$dianaz= substr($fecha,0,2); // fecha ... donde la leiste?
$mesnaz= substr($fecha,3,2);
$anonaz= substr($fecha,6,4);
}
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
Val: 557
Bronce
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

variable que se pierde

Publicado por movick (1056 intervenciones) el 04/10/2014 03:04:01
que tal a todos.Bueno voy a enviar el codigo completo a ver. Disculpen lo largo que pueda ser:


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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
<?php
   $connect = pg_connect("host=localhost port=5432 dbname=pediatria user=postgres password=1234");
   $vacunas = "SELECT * FROM vacunas ORDER BY descripcion";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
      <script language="JavaScript" src="calendario.js"></script>
      <script language="JavaScript" src="overlib_mini.js"></script>
<SCRIPT type="text/javascript">
var patron = new Array(2,2,4)
var patron2 = new Array(1,3,3,3,3)
function mascara(d,sep,patron,nums){
if(d.valant != d.value){
	val = d.value
	largo = val.length
	val = val.split(sep)
	val2 = ''
	for(r=0;r<val.length;r++){
		val2 += val[r]
	}
	if(nums){
		for(z=0;z<val2.length;z++){
		  if(isNaN(val2.charAt(z))){
			letra = new RegExp(val2.charAt(z),"g")
			val2 = val2.replace(letra,"")
		   }
		}
	}
	val = ''
	val3 = new Array()
	for(s=0; s<patron.length; s++){
		val3[s] = val2.substring(0,patron[s])
		val2 = val2.substr(patron[s])
	}
	for(q=0;q<val3.length; q++){
		if(q ==0){
			val = val3[q]
		}
		else{
			if(val3[q] != ""){
				val += sep + val3[q]
			}
		}
	}
	d.value = val
	d.valant = val
	}
}
 
 
/***/
function validatePass(campo) {
    var RegExPattern = /(^[0-9]+.[0-9]+$)/;
    var errorMessage = 'Debe Escribir el Peso con un punto y decimales';
    if ((campo.value.match(RegExPattern)) && (campo.value!='')) {
    } else {
        alert(errorMessage);
        campo.focus();
    }
}
 
function validateTalla(talla) {
    var RegExPattern = /(^[0-9]+.[0-9]+$)/;
    var errorMessage = 'Debe Escribir la Talla con un punto y decimales';
    if ((talla.value.match(RegExPattern)) && (talla.value!='')) {
    } else {
        alert(errorMessage);
        talla.focus();
    }
}
 
function validateCircEncef(circenc) {
    var RegExPattern = /(^[0-9]+.[0-9]+$)/;
    var errorMessage = 'Debe Escribir el Perimetro Craneal con un punto y decimales';
    if ((circenc.value.match(RegExPattern)) && (circenc.value!='')) {
    } else {
        alert(errorMessage);
        circenc.focus();
    }
}
 
function validateCircBrazo(circbra) {
    var RegExPattern = /(^[0-9]+.[0-9]+$)/;
    var errorMessage = 'Debe Escribir la Circunferencia del Brazo con un punto y decimales';
    if ((circbra.value.match(RegExPattern)) && (circbra.value!='')) {
    } else {
        alert(errorMessage);
        circbra.focus();
    }
}
 
function isValidDate(day,month,year)
{
    var dteDate;
 
    // En javascript, el mes empieza en la posicion 0 y termina en la 11 
    //   siendo 0 el mes de enero
    // Por esta razon, tenemos que restar 1 al mes
    month=month-1;
    // Establecemos un objeto Data con los valore recibidos
    // Los parametros son: año, mes, dia, hora, minuto y segundos
    // getDate(); devuelve el dia como un entero entre 1 y 31
    // getDay(); devuelve un num del 0 al 6 indicando siel dia es lunes,
    //   martes, miercoles ...
    // getHours(); Devuelve la hora
    // getMinutes(); Devuelve los minutos
    // getMonth(); devuelve el mes como un numero de 0 a 11
    // getTime(); Devuelve el tiempo transcurrido en milisegundos desde el 1
    //   de enero de 1970 hasta el momento definido en el objeto date
    // setTime(); Establece una fecha pasandole en milisegundos el valor de esta.
    // getYear(); devuelve el año
    // getFullYear(); devuelve el año
    dteDate=new Date(year,month,day);
    //alert(((day==dteDate.getDate()) && (month==dteDate.getMonth()) && (year==dteDate.getFullYear())));
    //Devuelva true o false...
    return ((day==dteDate.getDate()) && (month==dteDate.getMonth()) && (year==dteDate.getFullYear()));
}
 
 
 
function calcularEdad()
{
    var fecha=document.getElementById("user_date").value;
 
        var values=fecha.split("/");
        var dia = values[0];
        var mes = values[1];
        var ano = values[2];
        fecha=	dia+"/"+mes	+"/"+ano;
 
    if(validate_fecha(fecha)==true)
    {
        // Si la fecha es correcta, calculamos la edad
        var values=fecha.split("/");
 
		var dia = values[0];
        var mes = values[1];
        var ano = values[2];
		alert(ano);
        // cogemos los valores actuales
        var fecha_hoy = new Date();
        var ahora_ano = fecha_hoy.getYear();
        var ahora_mes = fecha_hoy.getMonth();
        var ahora_dia = fecha_hoy.getDate();
 
        // realizamos el calculo
        var edad = (ahora_ano + 1900) - ano;
        if ( ahora_mes < (mes - 1))
        {
            edad--;
        }
        if (((mes - 1) == ahora_mes) && (ahora_dia < dia))
        {
            edad--;
        }
        if (edad > 1900)
        {
            edad -= 1900;
        }
 
        document.getElementById("result").innerHTML="Tienes "+edad+" años";
    }else{
        document.getElementById("result").innerHTML="La fecha "+fecha+" es incorrecta";
    }
}
 
 
 
 
 
</script>
<title>Pacientes</title>
</head>
 
<body>
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
<form action="cargapacientes.php" method="POST" name="form1">
<!--<fieldset style='width:auto'><LEGEND>Ingreso Paciente</LEGEND> 
-->
<?php
$connect = pg_connect("host=localhost port=5432 dbname=pediatria user=postgres password=1234");
?>
   <table>
      <tr>
	    <td >Nro de Historia:</td>
<?php
$hoy=date('d-m-Y');
 
 
$query= pg_query("SELECT max(nrohistoria)+1 as MaxNroHistoria FROM paciente");
 if ($row = pg_fetch_row($query))
 {
  $id = str_pad(trim($row[0]),4,"0",STR_PAD_LEFT);
 }
?>
<td class='sr'><input type='text' readonly="T" value="<?php echo $id; ?>" name='nrohistoria' size='10' maxlength='10' align='right'/></td></tr>
	  <tr>
		<td class="sr" align='right' style="text-decoration:none">Nombres:</td>
		<td class="sr"><input type="text" name="nombres" size="50" maxlength="50" align="right"/></td>
	  </tr>
 
	  <tr>
		<td class="sr" align='right' style="text-decoration:none">Apellidos:</td>
		<td class="sr"><input type="text" name="apellidos" size="50" maxlength="50" align="right"/></td>
	  </tr>
 
	  <tr>
		<td class="sr" align='right' style="text-decoration:none">Direccion:</td>
		<td class="sr"><input type="text" name="direccion" size="120" maxlength="120" align="right"/>
		</td>
	  </tr>
	  <tr>
		<td class="sr" align='right' style="text-decoration:none">Telefono:</td>
		<td class="sr"><input type="text" name="telefono" size="10" maxlength="10" align="right"/>
		</td>
	  </tr>
 
 
<TR>
	<td>Fecha de Nac.:</td>
    <td><input type="text" size=10 maxlength=10 name="fechanac" onBlur="calcularEdad(this);" onKeyUp="mascara(this,'-',patron,true)" id="fechanac">
 
<?php
$dia=date('j');
$mes=date('n');
$ano=date('Y');
 
//fecha de nacimiento 
 
if (isset($_POST['fecha_n']) and $_POST['fecha_n']!="" ){
 $fecha=$_POST['fecha_n'];
 $dianaz= substr($fecha,0,2);
 $mesnaz= substr($fecha,3,2);
 $anonaz= substr($fecha,6,4);
 
}
else
{
 $dianaz= "";
 $mesnaz= "";
 $anonaz= "";
}
//si el mes es el mismo pero el dia inferior aun no ha cumplido años, le quitaremos un año al actual 
 
 
if (($mesnaz == $mes) && ($dianaz > $dia)) {
$ano=($ano-1); }
 
 
//si el mes es superior al actual tampoco abra cumplido años, por eso le quitamos un año al actual 
 
if ($mesnaz > $mes) {
$ano=($ano-1);}
 
//ya no habria mas condiciones, ahora simplemente restamos los años y mostramos el resultado como su edad 
 
$edad=($ano-$anonaz);
if (isset($_POST['fecha_n']) and $_POST['fecha_n']!=""){
print "Su edad es: ".$edad." a&ntilde;os.";
}else
{
print "No hay datos";
}
?>
</td>
</TR>
 
<tr>
     <td align='right'>Sexo:</td>
     <td><select name="cmbosexo"><option value="0">[Seleccione el Sexo]</option>
 
<?php
   $sexos = "SELECT * FROM sexo";
 
//*** crear la tabla sexo
$sexo = @pg_query($connect,$sexos);
while($selectsex = @pg_fetch_array($sexo))
          {
			$codigo = $selectsex['codigo'];
            $descripsex = $selectsex['descripcion'];
            echo "<OPTION VALUE='$codigo'>$descripsex</OPTION>";
          }
 
?>
        </select></td></tr>
 
<tr>
     <td align='right'>Grupo Sanguineo:</td>
     <td><select name="cmbosang"><option value="0">[Seleccione el Grupo Sanguineo]</option>
<?php
$gsang = "SELECT * FROM gsanguineo ORDER BY descripcion";
$gsang = @pg_query($connect,$gsang);
while($selectgsang = @pg_fetch_array($gsang))
          {
			$codigo = $selectgsang['codigo'];
            $descrip = $selectgsang['descripcion'];
            echo "<OPTION VALUE='$codigo'>$descrip</OPTION>";
          }
 
?>
        </select></td></tr>
<!---->
<tr>
     <td align='right' class='sr' >Hcm:</td>
     <td><select name="cmbotipgasto"><option value="0">[Seleccione una Clinica]</option>
<?php
$tipo_gasto = "SELECT * FROM hcm ORDER BY descripcion";
$tipo_gasto = @pg_query($connect,$tipo_gasto);
while($select3 = @pg_fetch_array($tipo_gasto))
		  {
			$cCodigo = $select3['codigo'];
            $descrip = $select3['descripcion'];
            echo "<OPTION VALUE='$cCodigo'>$descrip</OPTION>";
          }
?>
        </select></td></tr>
<!---->
 
</table>
</fieldset>
<table><tr><td><hr width="900" align="center"></td></tr></table>
<table align='center' border='1' bordercolor='#00CC99' bgcolor='#99CC00'>
  <tr>
	              <th>Fecha:
		     	       <td><input type='text' value=<?php echo $hoy?> name='fecha' readonly='.F.'></td></tr>
  <tr>
 
           <th width='100' style='font-size:15px;'>Peso:
		               <td><input type='text' name='peso' onBlur="validatePass(this);"></td></tr>
  <tr>
           <th width='100' style='font-size:15px;'>Talla:
		     	       <td><input type='text' name='talla' onBlur="validateTalla(this);"></td></tr>
  <tr>
           <th width='100' style='font-size:15px;'>Circ Encef:
		     	       <td><input type='text' name='circenf' onBlur="validateCircEncef(this);"></td></tr>
  <tr>
           <th width='100' style='font-size:15px;'>Circ Brazo:
		     	       <td><input type='text' name='circbrazo' onBlur="validateCircBrazo(this);"></td></tr>
<?php
/*$SqlCommand="update MiTabla set HepatitisA='$HepatitisA',HepatitisB='$HepatitisB'
where IdPaciente='$IdPaciente' ";*/
?>
  <tr>
           <th width='100' style='font-size:15px;'>
   		   Hepatitis A:<td>
		   <input name="checkhepa" type="checkbox" value="Hepa">
           Polio:
		   <input name="checkpoli" type="checkbox" value="Poli">
           Fiebre Amarilla:
		   <input name="checkfieama" type="checkbox" value="">
    	   Difteria-Tetanos:
		   <input name="difteriateta" type="checkbox" value="">
		   Varicela:
		   <input name="varicela" type="checkbox" value="">
		   Meningitis Meningococia:
		   <input name="meningitis" type="checkbox" value="">
		</td>
 
  <tr>
           <th width='100' style='font-size:15px;'>
		   Hepatitis B:<td>
		   <input name="checkhepb" type="checkbox" value="Hepab">
		   Haemophilus Influenza:
		   <input name="checkinfluenzae" type="checkbox" value="">
		   Sarampion Rubeola Parotiditis:
		   <input name="checksaramp" type="checkbox" value="">
		   Vph:
		   <input name="checkvph" type="checkbox" value="">
		   Rotavirus:
		   <input name="checkrotavirus" type="checkbox" value="">
		   Tuberculosis:
		   <input name="checktuberculosis" type="checkbox" value="">
  	    </td>
  </tr>
  <tr>
           <th width='100' style='font-size:15px;'>Consulta:
		     	       <td><textarea name='consulta' cols='70' rows='5'></textarea></td></tr>
 
	   </table>
 
<table align="center">
   <tr>
    <td>
         <input class="color1" type="submit" name="action" value="Guardar"/>
         <input class="color1" type="reset" value="Deshacer">
    </td>
    </tr>
</table>
 
</form>
 
 
 
 
</body>
 
</html>
ayudenme por favor, mientras tanto yo tambien seguire buscando la solucion.
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
Val: 557
Bronce
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

variable que se pierde

Publicado por movick (1056 intervenciones) el 04/10/2014 21:01:18
Si, en realidad el codigo es muy largo y tedioso, disculpen no es obligado que lo revisen, vere como resuelvo esto.
Saludos.
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
Val: 557
Bronce
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

variable que se pierde

Publicado por movick (1056 intervenciones) el 04/10/2014 02:43:41
Xve disculpa pero yo estoy recargando otro formulario uno de nombre cargapacientes.php y el formulario principal se llama pacientes.php, esto es debido a que desde el pacientes.php recojo todas las variables que se van a guardar en la base de datos desde pacientes.php
llamo este 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
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
<?php
$conexion = pg_connect("host=localhost port=5432 dbname=pediatria user=postgres password=1234");
$NroHistoria = $_POST['nrohistoria'];
$nombres = $_POST['nombres'];
$apellidos = $_POST['apellidos'];
$direccion = $_POST['direccion'];
$telefono = $_POST['telefono'];
$fecha_nac = $_POST['fechanac'];
 
$sexo = $_POST['cmbosexo'];
$gsanguineo = $_POST['cmbosang'];
 
$fecha = $_POST['fecha'];
$anio  = substr($fecha,6,4);
$mes   = substr($fecha,3,2);
$dia   = substr($fecha,0,2);
$fecha = $anio."-".$mes."-".$dia;
$peso = $_POST['peso'];
$talla = $_POST['talla'];
$circunf = $_POST['circenf'];
$cirbrazo = $_POST['circbrazo'];
$consulta = $_POST['consulta'];
$edad = $_POST['fechanac'];
$hcm = $_POST['cmbotipgasto'];
 
/*$hepatitisa ="";
$hepatitisb ="";
$polio = "";
*/
 
if(isset($_POST['checkhepa']))
{
 $hepatitisa=$_POST['checkhepa'];
  if($hepatitisa){
     $hepatitisa = true;
   }
  else
   {
     $hepatitisa = false;
   }
}
 
if(isset($_POST['checkhepb']))
{
 $hepatitisb=$_POST['checkhepb'];
  if($hepatitisb){
     $hepatitisb = true;
   }
  else
  {
     $hepatitisb = false;
  }
}
 
 
if(isset($_POST['checkpoli']))
{
 $polio = $_POST['checkpoli'];
  if($polio){
  $polio= true;
  }
  else{
  $polio = false;
  }
}
 
 
 
 
/*$hepatitisa = $_POST['checkhepa'];
$hepatitisb=$_POST['checkhepb'];
$polio = $_POST['checkpoli'];*/
/****/
$paciente = "INSERT INTO paciente(
					nrohistoria,
					nombre,
					direccion,
					telefono,
					fecha_nac,
					cod_sexo,
					cod_sanguineo)
			 VALUES ($NroHistoria,
			 		'$nombres',
					'$direccion',
					$telefono,
					'$fecha_nac',
					$sexo,
					$gsanguineo)";
    $agregapaciente  = @pg_query($conexion,$paciente);
 
/****/
$consulta = "INSERT INTO consulta(
					fecha,
					peso,
					talla,
					edad,
					cod_hcm,					 
					circunfcefalica,
					circunfbrazo,
					observacion,
					polio,
					hepatitisa,
					hepatitisb) 
			 VALUES ('$fecha',
			 		$peso,
					$talla,
					15,
					$hcm,					 
					$circunf,
					$cirbrazo,
					'$consulta',
					'$polio',
					'$hepatitisa',
					'$hepatitisb')";
    $agrega  = @pg_query($conexion,$consulta);
?>
en el primer formulario debo calcular la edad del paciente a partir de la fecha de nacimiento. Alli es donde no se como hacer para calcular esta bendita edad.
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
Val: 557
Bronce
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

variable que se pierde

Publicado por movick (1056 intervenciones) el 05/10/2014 03:24:02
Bueno ya resolvi el problema pero lo resolvi en el formulario que procesa la informacion:
Aunque la idea era que lo calculara en el formulario principal que realiza el submit, ya que el objetivo es que el usuario observe la edad del niño cuando este cargando los datos.
si pueden comentar.
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
<?php
$conexion = pg_connect("host=localhost port=5432 dbname=pediatria user=postgres password=1234");
$NroHistoria = $_POST['nrohistoria'];
$nombres = $_POST['nombres'];
$apellidos = $_POST['apellidos'];
$direccion = $_POST['direccion'];
$telefono = $_POST['telefono'];
$fecha_nac = $_POST['fechanac'];
 
$date2 = date('Y-m-d');//la fecha del computador
 
echo "</br>";
 
echo $diff = abs(strtotime($date2) - strtotime($fecha_nac));
echo "</br> Años";
echo $edad = floor($diff / (365*60*60*24));
 
 
$sexo = $_POST['cmbosexo'];
$gsanguineo = $_POST['cmbosang'];
 
$fecha = $_POST['fecha'];
$anio  = substr($fecha,6,4);
$mes   = substr($fecha,3,2);
$dia   = substr($fecha,0,2);
$fecha = $anio."-".$mes."-".$dia;
$peso = $_POST['peso'];
$talla = $_POST['talla'];
$circunf = $_POST['circenf'];
$cirbrazo = $_POST['circbrazo'];
$consulta = $_POST['consulta'];
$hcm = $_POST['cmbotipgasto'];
 
if(isset($_POST['checkhepa']))
{
 $hepatitisa=$_POST['checkhepa'];
  if($hepatitisa){
     $hepatitisa = true;
   }
  else
   {
     $hepatitisa = false;
   }
}
 
if(isset($_POST['checkhepb']))
{
 $hepatitisb=$_POST['checkhepb'];
  if($hepatitisb){
     $hepatitisb = true;
   }
  else
  {
     $hepatitisb = false;
  }
}
 
 
if(isset($_POST['checkpoli']))
{
 $polio = $_POST['checkpoli'];
  if($polio){
  $polio= true;
  }
  else{
  $polio = false;
  }
}
 
/****/
$paciente = "INSERT INTO paciente(
					nrohistoria,
					nombre,
					direccion,
					telefono,
					fecha_nac,
					cod_sexo,
					cod_sanguineo)
			 VALUES ($NroHistoria,
			 		'$nombres',
					'$direccion',
					$telefono,
					'$fecha_nac',
					$sexo,
					$gsanguineo)";
    $agregapaciente  = @pg_query($conexion,$paciente);
 
/****/
$consulta = "INSERT INTO consulta(
					fecha,
					peso,
					talla,
					edad,
					cod_hcm,					 
					circunfcefalica,
					circunfbrazo,
					observacion,
					polio,
					hepatitisa,
					hepatitisb) 
			 VALUES ('$fecha',
			 		$peso,
					$talla,
					$edad,
					$hcm,					 
					$circunf,
					$cirbrazo,
					'$consulta',
					'$polio',
					'$hepatitisa',
					'$hepatitisb')";
    $agrega  = @pg_query($conexion,$consulta);
?>
adjunto el formulario principal:
formpaciente
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