Ver Mensaje Individual
  #13 (permalink)  
Antiguo 05/05/2012, 19:06
Avatar de chwc
chwc
 
Fecha de Ingreso: julio-2008
Ubicación: Buenos Aires ! :D
Mensajes: 814
Antigüedad: 15 años, 9 meses
Puntos: 103
Respuesta: Error en strlen

entonces, hace una cosa, digamos que $error=0 significa todo bien, $error=1 significa error en el titulo, y error=2 significa error en la nota, entonces
Código PHP:
Ver original
  1. <?php
  2. $error=0;
  3. //validacion
  4. if(strlen($_POST['titulo'])==0){ //strlen te dice cuanto mide una variable
  5. * * $error=1;
  6. }else{
  7. * * $titulo=$_POST['titulo'];
  8. }
  9. if(strlen($_POST['nota'])==0){
  10. * * $error=2;
  11. }else{
  12. * * $nota=$_POST['nota'];
  13. }
  14. //cierre validacion
  15. *
  16. if($error=1)
  17. * * * * echo "<h3> Error en el titulo </h3>";
  18. if($error=2)
  19. * * * * * * echo "<h3> Error en la nota </h3>";
  20. if($error=3){
  21. * * * *
  22. * * if(file_exists("mensajes.txt")){
  23. * * * * $db=unserialize(file_get_contents("mensajes.txt"));
  24. * * }else{
  25. * * * * $db=array();
  26. * * }
  27. * * $fila=array();
  28. * * $fila['titulo']=$titulo;
  29. * * $fila['nota']=$nota;
  30. * * $db[]=$fila;
  31. * * file_put_contents("mensajes.txt",serialize($db));
  32. * * echo "<h1>GUARDADO</h1>";
  33. }
  34. ?>
asi creo que funcionaria bien :D
denada por hacerte la tarea XD
saludos y suerte