Ver Mensaje Individual
  #2 (permalink)  
Antiguo 08/05/2010, 12:20
den_22
 
Fecha de Ingreso: enero-2010
Mensajes: 198
Antigüedad: 14 años, 4 meses
Puntos: 1
Respuesta: Mensaje con echo

Cambie un par de cosas, el mensaje de error lo muestra, pero si no hay ningun caracter especial, y está todo bien, la pagina con la div cont_succes no se muestra y no aparece el datos guardados con exito.

Código PHP:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es-es">
  3. <head>
  4. <?php
  5. error_reporting(E_ALL ^ E_NOTICE);
  6. session_name('pLogin');
  7. include('connect.php'); //incluimos el config.php que contiene los datos de la conexi&oacute;n a la db
  8. $usuario=$_SESSION['usuario'];
  9.  
  10.  
  11. $errcnt=0;
  12. if(count($_POST)<>0)        //IF SOME FORM WAS POSTED DO VALIDATION
  13. {
  14.         {
  15.             $firstname=str_replace("$","\$",addslashes($_REQUEST["firstname"]));
  16.             $lastname=str_replace("$","\$",addslashes($_REQUEST["lastname"]));
  17.             $ocupacion=str_replace("$","\$",addslashes($_REQUEST["ocupacion"]));
  18.  
  19.  
  20. }
  21.         else
  22.         {
  23.            
  24.             $firstname=str_replace("$","\$",addslashes($_REQUEST["firstname"]));
  25.             $lastname=str_replace("$","\$",addslashes($_REQUEST["lastname"]));
  26.             $ocupacion=str_replace("$","\$",addslashes($_REQUEST["ocupacion"]));
  27.  
  28.  
  29. }
  30. if ( strlen(trim($firstname)) == 0 )
  31.     {
  32.         $errs[$errcnt]="Firstname must be provided";
  33.         $errcnt++;
  34.     }
  35.     elseif(preg_match ("/[;<>&]/", $_REQUEST["firstname"]))
  36.     {
  37.         $errs[$errcnt]="Firstname can not have any special character (e.g. & ; < >)";
  38.         $errcnt++;
  39.     }
  40.  
  41.     if ( strlen(trim($lastname)) == 0 )
  42.     {
  43.         $errs[$errcnt]="Lastname must be provided";
  44.         $errcnt++;
  45.     }
  46.     elseif(preg_match ("/[;<>&]/", $_REQUEST["lastname"]))
  47.     {
  48.         $errs[$errcnt]="Lastname can not have any special character (e.g. & ; < >)";
  49.         $errcnt++;
  50.     }
  51.  
  52.     if ( strlen(trim($ocupacion)) == 0 )
  53.     {
  54.         $errs[$errcnt]="Ocupacion debe ser completada";
  55.         $errcnt++;
  56.     }
  57.     elseif(preg_match ("/[;<>&]/", $_REQUEST["ocupacion"]))
  58.     {
  59.         $errs[$errcnt]="Ocupacion no debe tener caracteres especiales (e.g. & ; < >)";
  60.         $errcnt++;
  61.     }
  62.    
  63.  
  64.  
  65. if($errcnt==0)
  66. {
  67.     mysql_query("
  68. UPDATE members
  69. SET firstname='".trim($firstname)."',lastname='".trim($lastname)."',ocupacion='$ocupacion'
  70. WHERE usuario='$_SESSION[usuario]'  ");
  71. }
  72. if  (count($_POST)>0)
  73. {
  74. $firstname=$_REQUEST["firstname"];
  75. $lastname=$_REQUEST["lastname"];
  76. $ocupacion=$_REQUEST["ocupacion"];
  77.  
  78. if ( $errcnt<>0 )
  79. {
  80. ?>
  81.  
  82.  
  83.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  84.    
  85.  
  86.     <title>prueba</title>
  87.  
  88.  
  89. </head>
  90.  
  91. <body>
  92.  
  93. <div id="prueba">
  94.   <tr>
  95.     <td colspan="2"><strong>No se pudo ejecutar el update debido a las siguientes razones</strong></td>
  96.   </tr>
  97.   <tr height="10">
  98.     <td colspan="2"></td>
  99.   </tr>
  100.   <?php
  101.  
  102. for ($i=0;$i<$errcnt;$i++)
  103. {
  104. ?>
  105.   <tr valign="top">
  106.     <td width="6%">&nbsp;<?php echo $i+1;?></td>
  107.     <td width="94%"><?php echo  $errs[$i]; ?></td>
  108.   </tr>
  109.   </div>
  110.  <?php
  111. }
  112. ?>
  113. <div id="cont_success">
  114. <?php
  115. }
  116. }
  117.  
  118. else{
  119. ?>
  120. <td width="94%"><?php echo '<span class="Estilo24">Datos Guardados con éxito</span>'; ?></td>
  121. </table>
  122. <?php
  123. }
  124. }
  125. ?>
  126. </div>