Ver Mensaje Individual
  #10 (permalink)  
Antiguo 05/05/2012, 18:26
Andress_mdq92
 
Fecha de Ingreso: abril-2012
Mensajes: 36
Antigüedad: 12 años, 10 meses
Puntos: 1
Respuesta: Error en strlen

Código PHP:
Ver original
  1. <?php
  2. $error=array();
  3. //validacion
  4. if(strlen($_POST['titulo'])==0){ //strlen te dice cuanto mide una variable
  5.     $error['titulo']="si";
  6. }else{
  7.     $titulo=$_POST['titulo'];
  8.     $error['titulo']="no";
  9. }
  10. if(strlen($_POST['nota'])==0){
  11.     $error['nota']="si";
  12. }else{
  13.     $nota=$_POST['nota'];
  14.     $error['nota']="no";
  15. }
  16. //cierre validacion
  17.  
  18. if(count($error)>0){
  19.     if($error['titulo']=="si"){
  20.         echo "<h3> Error en el titulo </h3>";
  21.     }
  22.         if($error['nota']=="si"){
  23.             echo "<h3> Error en la nota </h3>";
  24.         }
  25.         echo "<h3> ERROR: ¡NO SE GUARDO! </h3>";
  26.     }else{
  27.        
  28.     if(file_exists("mensajes.txt")){
  29.         $db=unserialize(file_get_contents("mensajes.txt"));
  30.     }else{
  31.         $db=array();
  32.     }}
  33.     $fila=array();
  34.     $fila['titulo']=$titulo;
  35.     $fila['nota']=$nota;
  36.     $db[]=$fila;
  37.     file_put_contents("mensajes.txt",serialize($db));
  38.     echo "<h1>GUARDADO</h1>";
  39.    
  40.  
  41. ?>