Ver Mensaje Individual
  #1 (permalink)  
Antiguo 16/09/2008, 04:11
Llaner
 
Fecha de Ingreso: septiembre-2008
Mensajes: 9
Antigüedad: 15 años, 8 meses
Puntos: 0
Problema comprobando datos de un formulario

Hoal a todos, mi problema es que tengo un formulario en html y cuando lo relleno hago una seri de comprobaciones en PHP para meter los datos en una base de datos, pero no pasa algunos datos correctamente, os dejo el codigo y os explico mejor
Código:
<tr><td height="200">
    <table cellpadding="0" width="500" align="center">
      <FORM name="hall" ACTION="?s=earth&a=upload" METHOD="post" enctype="multipart/form-data">
        <input type="hidden" name="MAX_FILE_SIZE" value="300000">
        <tr> <!--onfocus="MM_validateForm('from','','R','email','','RisEmail','date','','R','location','','R','comment','','R','comment2','','R');return document.MM_returnValue" -->
          <td valign="top" bgcolor="#CCCCCC">
            <p>
              Escoge tu imagen:<br>
              <input type="file" name="imagen" value="">
              <br>
              <span style="color: #FF0000">*</span> Tu nombre: <br>
 			  <input name="from" type="text" value="">
              <br>
              <span style="color: #FF0000">*</span> Tu Email: <br>
			  <input type="text" name="email" value="">
              <br>
              Fecha de la fotograf&iacute;a:<br>
              <input type="text" name="date" value="">
              <br>
              Poblaci&oacute;n: <br>
			  <input type="text" name="location" value="">			
              </p></td>
			  <td align="left" valign="top" bgcolor="#CCCCCC"><p>
			    <span style="color: #FF0000">*</span> T&iacute;tulo de la foto:<br> 
			    <input name="comment" type="text" value="" size="26">
			    </p>
			    <p><span style="color: #FF0000">*</span> C&oacute;digo de barras de tu calabaza Kernel :<br>
			      <input name="comment2" type="text" value="" size="26">
  </p>
			    <p>
			      <input name="checkbox" type="checkbox" value="checkbox">
			      Acepto los t&eacute;rminos y las condiciones de las <a href="http://www.kernelexport.es/halloween/bases.html">bases del concurso</a>.			  </p>
			    <p><input type="button" onClick="javascript:checkFields();" value="<?=$earth_submit_image ?>" name="enviar"></p>
			    <p>&nbsp;</p></td>
		  </tr>
        </FORM>
		  <tr>
		    <td colspan="2" valign="top" bgcolor="#CCCCCC"><p style="color: #FF0000">Los campos marcados con un * son obligatorios.</p></td>
		    </tr>
      </table>
  </td></tr>
y el php
Código:
<?php
$tam = sprintf("%u", filesize($imagen));
if ($comment2!= "xxxxxxxxxxxxx") {
	$seccion_contenido .= "$earth_submit_cb";
} else {
	if ($imagen!= "" AND $tam<300000){
		//$ruta = $_SERVER["DOCUMENT_ROOT"];
		$sql= "SELECT MAX(earth_id) AS mid FROM laken_earth";
		$resultado = bd_consultar($sql, $enlacebd);
		$fila = bd_llenar_array ($resultado);
		$foto=$fila["mid"]+1;
		$tipoarchivo=$HTTP_POST_FILES['imagen']['type'];
		if (strpos($tipoarchivo, "gif")){
			$foto=$foto.".gif";
		} elseif (strpos($tipoarchivo, "jpg")){
			$foto=$foto.".jpg";
		} elseif (strpos($tipoarchivo, "jpeg")){
			$foto=$foto.".jpeg";
		} elseif (strpos($tipoarchivo, "bmp")){
			$foto=$foto.".bmp";
		} else {
			$foto=$foto.substr($tipoarchivo,strlen($tipoarchivo)-3,3);
		}

		if (is_uploaded_file($HTTP_POST_FILES['imagen']['tmp_name']) AND move_uploaded_file($HTTP_POST_FILES['imagen']['tmp_name'],"$ruta_ima/lakenonearth/$foto")){ 
			chmod( "$ruta_ima/lakenonearth/$foto", 0644 );  
			$seccion_contenido = "$earth_submit_ok $foto (". $imagen_size / 1000 ." bytes)";
			$sql = "INSERT INTO laken_earth (earth_image,earth_date,earth_comment,earth_location,earth_from,earth_email) VALUES('$foto','$date','$comment','$location','$from','$email')";
			if($resultado = bd_consultar($sql, $enlacebd)){
				$seccion_contenido .= "<br> Imagen grabada correctamente";
			}else{
				$seccion_contenido .= "<br>$earth_submit_insert";
			}
		}else{
			$seccion_contenido .= "$earth_submit_error $foto";
		}
	} else {
		if ($tam>300000){$seccion_contenido.="$earth_submit_maxsize ". $imagen_size/1000;
		} else {
			$seccion_contenido .= "$earth_submit_eblank";	
			$seccion_contenido .= $tam;
			$seccion_contenido .= $imagen_size;
		}
	}
}
$go_back .= '<a href="javascript:history.back()" class="earth">'.$earth_submit_back.'</a>';
$seccion_cuerpo = "$ruta_tpl/earth_upload.html";
?>
Tengo varios problemas,al principio comprueba el tamaño del fichero de imagen, pero si es inferior al tamaño que pongo lo hace bien, pero si es superior no me da el error que es superior sino que no he seseccionado archivo y el tamaño me da 0.

Bueno espero que me hayais entendido y que podais ayudarme.

Muchas Gracias.

Última edición por Llaner; 16/09/2008 a las 05:54