here is my code
<form method="post" action="do.php" enctype="multipart/form-data">
<input type="hidden" name="do" value="addproperty">
Tipo de propiedad:
<select id="tipoprop" name=tipo onChange="seleccionaForma()">
<option value="0">Selecciona</option>
<option value="1">Casa</option>
<option value="2">Departamento</option>
<option value="3">Terreno</option>
<option value="4">Local comercial</option>
<option value="5">Otra</option>
<option value="6">Preventa</option>
<option value="7">Promocion</option>
<option value="8">Oportunidad</option>
</select>
Clave:
<input type=text style="font-size: 16px; color: #888;" size=10 name="codigo">
Ubicación: <select name="ciudad"><?
$sql="SELECT * FROM ubicaciones WHERE padre!='0' ORDER BY ubicacion";
$result=mysql_query($sql);
while($row=mysql_fetch_assoc($result)){
$sq="SELECT * FROM ubicaciones WHERE id='".$row["padre"]."'";
$re=mysql_query($sq);
$ro=mysql_fetch_assoc($re);
?>
<option value="<?=$row["id"]?>"><?=ucwords($row["ubicacion"])?>, <?=ucwords($ro["ubicacion"])?></option>
<? } ?>
</select>
Operación:
<select id="operacion" name="operacion" onChange="seleccionaTiempo()"><option value="1">Venta</option>
<option value="2">Renta</option></select>
<br />
<div id="plazo" style="display: none;">
Periodo de renta: <select name="periodo"><option value="1">Diario</option><option value="2">Fin de semana</option>
<option value="3">Semana</option><option value="4">Mes</option><option value="5">Año</option></select>
</div>
<br />
<div id="formacasas" style="display: none;">
<div id="casascampos" style="width: 650px; text-align: right;">
Superficie: <input type=text name="casasarea"> m²
Construcción: <input type=text name="casasconstruccion"> m² <br />
Niveles: <input type=text name="casaspisos" size=3>
Recámaras: <input type=text name="casasrecamaras" size=2> Baños: <input type=text name="casasbanos" size=2>
Precio: <input type=text name="casasprecio" size=10> <select style="display: none;" name="casasdivisa"><option value="MXN">Pesos Mexicanos</option>
<option value="USD">Dólares americanos</option><option value="CAN">Dólares canadienses</option><option value="EUR">Euros</option></select>
</div>
<br />Descripción:<br />
<textarea cols="80" id="casastexto" name="casastexto" rows="10" style="float: left;"></textarea>
<script type="text/javascript">
//<![CDATA[
CKEDITOR.replace( 'casastexto', { toolbar : 'MyTool',
toolbar_MyTool : [ ['Source','-','Undo','Redo','-','Find','Replace'],
['Bold','Italic','Underline','Strike','TextColor','BGColor','Font','FontSize'],'/',
['Link','Unlink','Anchor','Image','Smile','PageBreak'],
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','Table','HorizontalRule']],language : 'es' } );
//]]>
</script>
<br /><br />
Imágenes de la propiedad:<br /><br />
<input type=file name="casasimagen0"><br />
<input type=file name="casasimagen1"><br />
<input type=file name="casasimagen2"><br />
<input type=file name="casasimagen3"><br />
<input type=file name="casasimagen4"><br />
<input type=file name="casasimagen5"><br />
<input type=file name="casasimagen6"><br />
<input type=file name="casasimagen7"><br />
<input type=file name="casasimagen8"><br />
<input type=file name="casasimagen9"><br /><br />
<input type=submit value="Agregar casa"><input type=button value="Cancelar" onClick="reseteaForma()">
</div>
<div id="formadepartamentos" style="display: none;">
</div>
<div id="formaterrenos" style="display: none;">
</div>
<div id="formalocales" style="display: none;">
<div id="localescampos" style="width: 450px; text-align: right;">
Superficie: <input type=text name="localesarea"> m2<br />
Construcción: <input type=text name="localesconstruccion"> m2<br />
Precio: <input type=text name="localesprecio" size=10> <select style="display: none;" name="localesdivisa"><option value="MXN">Pesos Mexicanos</option>
<option value="USD">Dólares americanos</option><option value="EUR">Euros</option></select>
</div><br />Descripción:<br /><br />
<textarea cols="80" id="localestexto" name="localestexto" rows="10" style="float: left;"></textarea>
<script type="text/javascript">
//<![CDATA[
CKEDITOR.replace( 'localestexto', { toolbar : 'MyTool',
toolbar_MyTool : [ ['Source','-','Undo','Redo','-','Find','Replace'],
['Bold','Italic','Underline','Strike','TextColor','BGColor','Font','FontSize'],'/',
['Link','Unlink','Anchor','Image','Smile','PageBreak'],
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','Table','HorizontalRule']],language : 'es' } );
//]]>
</script>
<br /><br />
Imágenes de la propiedad:<br /><br />
<input type=file name="localesimagen0"><br />
<input type=file name="localesimagen1"><br />
<input type=file name="localesimagen2"><br />
<input type=file name="localesimagen3"><br />
<input type=file name="localesimagen4"><br />
<input type=file name="localesimagen5"><br />
<input type=file name="localesimagen6"><br />
<input type=file name="localesimagen7"><br />
<input type=file name="localesimagen8"><br />
<input type=file name="localesimagen9"><br /><br />
<input type=submit value="Agregar local comercial"><input type=button value="Cancelar" onClick="reseteaForma()">
</div>
<div id="formaotras" style="display: none; height: 800px;">
<div id="otrascampos" style="width: 450px; text-align: right;">
Superficie: <input type=text name="otrasarea"> m2<br />
Construcción: <input type=text name="otrasconstruccion"> m2<br />
Precio: <input type=text name="otrasprecio" size=10> <select name="otrasdivisa" style="display: none;"><option value="MXN">Pesos Mexicanos</option>
<option value="USD">Dólares americanos</option><option value="EUR">Euros</option></select>
</div><br />Descripción:<br /><br />
<textarea cols="80" id="otrastexto" name="otrastexto" rows="10" style="float: left;"></textarea>
<script type="text/javascript">
//<![CDATA[
CKEDITOR.replace( 'otrastexto', { toolbar : 'MyTool',
toolbar_MyTool : [ ['Source','-','Undo','Redo','-','Find','Replace'],
['Bold','Italic','Underline','Strike','TextColor','BGColor','Font','FontSize'],'/',
['Link','Unlink','Anchor','Image','Smile','PageBreak'],
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','Table','HorizontalRule']],language : 'es' } );
//]]>
</script>
<br /><br />
Imágenes de la propiedad:<br /><br />
<input type=file name="otrasimagen0"><br />
<input type=file name="otrasimagen1"><br />
<input type=file name="otrasimagen2"><br />
<input type=file name="otrasimagen3"><br />
<input type=file name="otrasimagen4"><br />
<input type=file name="otrasimagen5"><br />
<input type=file name="otrasimagen6"><br />
<input type=file name="otrasimagen7"><br />
<input type=file name="otrasimagen8"><br />
<input type=file name="otrasimagen9"><br /><br />
<input type=submit value="Agregar propiedad de otro tipo"><input type=button value="Cancelar" onClick="reseteaForma()">
</div>
<div id="formapreventa" style="display: none;">
<div id="preventacampos" style="width: 650px; text-align: right;">
Superficie: <input type=text name="preventaarea"> m²
Construcción: <input type=text name="preventaconstruccion"> m² <br />
Niveles: <input type=text name="preventapisos" size=3>
Recámaras: <input type=text name="preventarecamaras" size=2> Baños: <input type=text name="preventabanos" size=2>
Precio: <input type=text name="preventaprecio" size=10>
<select style="display: none;" name="preventadivisa">
<option value="MXN">Pesos Mexicanos</option>
<option value="USD">Dólares americanos</option>
<option value="CAN">Dólares canadienses</option>
<option value="EUR">Euros</option></select>
</div><br />Descripción:<br />
<textarea cols="80" id="preventatexto" name="preventatexto" rows="10" style="float: left;"></textarea>
<script type="text/javascript">
//<![CDATA[
CKEDITOR.replace( 'preventatexto', { toolbar : 'MyTool',
toolbar_MyTool : [ ['Source','-','Undo','Redo','-','Find','Replace'],
['Bold','Italic','Underline','Strike','TextColor','BGColor','Font','FontSize'],'/',
['Link','Unlink','Anchor','Image','Smile','PageBreak'],
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','Table','HorizontalRule']],language : 'es' } );
//]]>
</script>
<br /><br />
Imágenes de la propiedad:<br /><br />
<input type=file name="preventaimagen0"><br />
<input type=file name="preventaimagen1"><br />
<input type=file name="preventaimagen2"><br />
<input type=file name="preventaimagen3"><br />
<input type=file name="preventaimagen4"><br />
<input type=file name="preventaimagen5"><br />
<input type=file name="preventaimagen6"><br />
<input type=file name="preventaimagen7"><br />
<input type=file name="preventaimagen8"><br />
<input type=file name="preventaimagen9"><br /><br />
<input type=submit value="Agregar preventa"><input type=button value="Cancelar" onClick="reseteaForma()">
</div>
<div id="formapromocion" style="display: none;">
<div id="promocioncampos" style="width: 650px; text-align: right;">
Superficie: <input type=text name="promarea"> m²
Construcción: <input type=text name="promocionconstruccion"> m² <br />
Niveles: <input type=text name="promocionpisos" size=3>
Recámaras: <input type=text name="promocionrecamaras" size=2> Baños: <input type=text name="promocionbanos" size=2>
Precio: <input type=text name="promocionprecio" size=10> <select style="display: none;" name="promociondivisa"><option value="MXN">Pesos Mexicanos</option>
<option value="USD">Dólares americanos</option><option value="CAN">Dólares canadienses</option><option value="EUR">Euros</option></select>
</div><br />Descripción:<br />
<textarea cols="80" id="promociontexto" name="promociontexto" rows="10" style="float: left;"></textarea>
<script type="text/javascript">
//<![CDATA[
CKEDITOR.replace( 'promociontexto', { toolbar : 'MyTool',
toolbar_MyTool : [ ['Source','-','Undo','Redo','-','Find','Replace'],
['Bold','Italic','Underline','Strike','TextColor','BGColor','Font','FontSize'],'/',
['Link','Unlink','Anchor','Image','Smile','PageBreak'],
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','Table','HorizontalRule']],language : 'es' } );
//]]>
</script>
<br /><br />
Imágenes de la propiedad:<br /><br />
<input type=file name="promocionimagen0"><br />
<input type=file name="promocionimagen1"><br />
<input type=file name="promocionimagen2"><br />
<input type=file name="promocionimagen3"><br />
<input type=file name="promocionimagen4"><br />
<input type=file name="promocionimagen5"><br />
<input type=file name="promocionimagen6"><br />
<input type=file name="promocionimagen7"><br />
<input type=file name="promocionimagen8"><br />
<input type=file name="promocionimagen9"><br /><br />
<input type=submit value="Agregar promocion"><input type=button value="Cancelar" onClick="reseteaForma()">
</div>
<div id="formaoportunidad" style="display: none;">
<div id="oportundidadcampos" style="width: 650px; text-align: right;">
Superficie: <input type=text name="oporarea"> m²
Construcción: <input type=text name="oporconstruccion"> m² <br />
Niveles: <input type=text name="oporpisos" size=3>
Recámaras: <input type=text name="prevrecamaras" size=2> Baños: <input type=text name="oporbanos" size=2>
Precio: <input type=text name=casasprecio size=10> <select style="display: none;" name="opordivisa"><option value="MXN">Pesos Mexicanos</option>
<option value="USD">Dólares americanos</option><option value="CAN">Dólares canadienses</option><option value="EUR">Euros</option></select>
</div><br />Descripción:<br />
<textarea cols="80" id="oportexto" name="oportexto" rows="10" style="float: left;"></textarea>
<script type="text/javascript">
//<![CDATA[
CKEDITOR.replace( 'oportexto', { toolbar : 'MyTool',
toolbar_MyTool : [ ['Source','-','Undo','Redo','-','Find','Replace'],
['Bold','Italic','Underline','Strike','TextColor','BGColor','Font','FontSize'],'/',
['Link','Unlink','Anchor','Image','Smile','PageBreak'],
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','Table','HorizontalRule']],language : 'es' } );
//]]>
</script>
<br /><br />
Imágenes de la propiedad:<br /><br />
<input type=file name="oportunidadimagen0"><br />
<input type=file name="oportunidadimagen1"><br />
<input type=file name="oportunidadimagen2"><br />
<input type=file name="oportunidadimagen3"><br />
<input type=file name="oportunidadimagen4"><br />
<input type=file name="oportunidadimagen5"><br />
<input type=file name="oportunidadimagen6"><br />
<input type=file name="oportunidadimagen7"><br />
<input type=file name="oportunidadimagen8"><br />
<input type=file name="oportunidadimagen9"><br /><br />
<input type=submit value="Agregar oportunidad"><input type=button value="Cancelar" onClick="reseteaForma()">
</div>
</form>
the error im having is when i submit the form and the option choosen is other than casas, it doesnt send the image, send all the data but image dont. i have tested all, rechecked all and nothing,
here is de do.php form
if($_POST["do"]=="addproperty" AND $_SESSION["logged"]==1){
include("../db.php");
if($_POST["operacion"]==1){ $oper=1; }
if($_POST["operacion"]==2 AND $_POST["periodo"]==1){ $oper=2; }
if($_POST["operacion"]==2 AND $_POST["periodo"]==2){ $oper=3; }
if($_POST["operacion"]==2 AND $_POST["periodo"]==3){ $oper=4; }
if($_POST["operacion"]==2 AND $_POST["periodo"]==4){ $oper=5; }
if($_POST["operacion"]==2 AND $_POST["periodo"]==5){ $oper=6; }
if($_POST["tipo"]==1){
$sql="INSERT INTO propiedades
(id,codigo,tipo,superficie,construccion,recamaras,banos,pisos,descripcion,precio,divisa,operacion,tipooper,ciudad,estado,vendida,oferta,fechaventa)
VALUES
('','".$_POST["codigo"]."','1','".$_POST["casasarea"]."','".$_POST["casasconstruccion"]."','".$_POST["casasrecamaras"]."',
'".$_POST["casasbanos"]."','".$_POST["casaspisos"]."','".$_POST["casastexto"]."','".$_POST["casasprecio"]."','".$_POST["casasdivisa"]."',
'".$oper."','".$_POST["operacion"]."','".$_POST["ciudad"]."','','0','0','0')";
$result=mysql_query($sql);
$imagenes="casas";
}
if($_POST["tipo"]==2){
$sql="INSERT INTO propiedades
(id,codigo,tipo,superficie,construccion,recamaras,banos,pisos,descripcion,precio,divisa,operacion,tipooper,ciudad,estado,vendida,oferta,fechaventa)
VALUES
('','".$_POST["codigo"]."','2','".$_POST["casasarea"]."','".$_POST["casasconstruccion"]."','".$_POST["casasrecamaras"]."',
'".$_POST["casasbanos"]."','".$_POST["casaspisos"]."','".$_POST["casastexto"]."','".$_POST["casasprecio"]."','".$_POST["casasdivisa"]."',
'".$oper."','".$_POST["operacion"]."','".$_POST["ciudad"]."','','0','0','0')";
$result=mysql_query($sql);
$imagenes="departamentos";
}
if($_POST["tipo"]==3){
$sql="INSERT INTO propiedades
(id,codigo,tipo,superficie,construccion,recamaras,banos,pisos,descripcion,precio,divisa,operacion,tipooper,ciudad,estado,vendida,oferta,fechaventa)
VALUES
('','".$_POST["codigo"]."','3','".$_POST["terrenosarea"]."','','',
'','','".$_POST["terrenostexto"]."','".$_POST["terrenosprecio"]."','".$_POST["terrenosdivisa"]."',
'".$oper."','".$_POST["operacion"]."','".$_POST["ciudad"]."','','0','0','0')";
$result=mysql_query($sql);
$imagenes="terrenos";
}
if($_POST["tipo"]==4){
$sql="INSERT INTO propiedades
(id,codigo,tipo,superficie,construccion,recamaras,banos,pisos,descripcion,precio,divisa,operacion,tipooper,ciudad,estado,vendida,oferta,fechaventa)
VALUES
('','".$_POST["codigo"]."','4','".$_POST["casasarea"]."','".$_POST["casasconstruccion"]."','".$_POST["casasrecamaras"]."',
'".$_POST["casasbanos"]."','".$_POST["casaspisos"]."','".$_POST["casastexto"]."','".$_POST["casasprecio"]."','".$_POST["casasdivisa"]."',
'".$oper."','".$_POST["operacion"]."','".$_POST["ciudad"]."','','0','0','0')";
$result=mysql_query($sql);
$imagenes="locales";
}
if($_POST["tipo"]==5){
$sql="INSERT INTO propiedades
(id,codigo,tipo,superficie,construccion,recamaras,banos,pisos,descripcion,precio,divisa,operacion,tipooper,ciudad,estado,vendida,oferta,fechaventa)
VALUES
('','".$_POST["codigo"]."','5','".$_POST["casasarea"]."','".$_POST["casasconstruccion"]."','".$_POST["casasrecamaras"]."',
'".$_POST["casasbanos"]."','".$_POST["casaspisos"]."','".$_POST["casastexto"]."','".$_POST["casasprecio"]."','".$_POST["casasdivisa"]."',
'".$oper."','".$_POST["operacion"]."','".$_POST["ciudad"]."','','0','0','0')";
$result=mysql_query($sql);
$imagenes="otras";
}
if($_POST["tipo"]==6){
$sql="INSERT INTO propiedades
(id,codigo,tipo,superficie,construccion,recamaras,banos,pisos,descripcion,precio,divisa,operacion,tipooper,ciudad,estado,vendida,oferta,fechaventa)
VALUES
('','".$_POST["codigo"]."','6','".$_POST["preventaarea"]."','".$_POST["preventaconstruccion"]."','".$_POST["preventarecamaras"]."',
'".$_POST["preventabanos"]."','".$_POST["preventapisos"]."','".$_POST["preventatexto"]."','".$_POST["preventaprecio"]."','".$_POST["preventadivisa"]."',
'".$oper."','".$_POST["operacion"]."','".$_POST["ciudad"]."','','0','0','0')";
$result=mysql_query($sql);
$imagenes="preventa";
}
if($_POST["tipo"]==7){
$sql="INSERT INTO propiedades
(id,codigo,tipo,superficie,construccion,recamaras,banos,pisos,descripcion,precio,divisa,operacion,tipooper,ciudad,estado,vendida,oferta,fechaventa)
VALUES
('','".$_POST["codigo"]."','7','".$_POST["promarea"]."','".$_POST["promconstruccion"]."','".$_POST["promrecamaras"]."',
'".$_POST["prombanos"]."','".$_POST["prompisos"]."','".$_POST["promtexto"]."','".$_POST["promprecio"]."','".$_POST["promdivisa"]."',
'".$oper."','".$_POST["operacion"]."','".$_POST["ciudad"]."','','0','0','0')";
$result=mysql_query($sql);
$imagenes="promocion";
}
if($_POST["tipo"]==8){
$sql="INSERT INTO propiedades
(id,codigo,tipo,superficie,construccion,recamaras,banos,pisos,descripcion,precio,divisa,operacion,tipooper,ciudad,estado,vendida,oferta,fechaventa)
VALUES
('','".$_POST["codigo"]."','8','".$_POST["oporarea"]."','".$_POST["oporconstruccion"]."','".$_POST["oporrecamaras"]."',
'".$_POST["oporbanos"]."','".$_POST["oporpisos"]."','".$_POST["oportexto"]."','".$_POST["casasprecio"]."','".$_POST["casasdivisa"]."',
'".$oper."','".$_POST["operacion"]."','".$_POST["ciudad"]."','','0','0','0')";
$result=mysql_query($sql);
$imagenes="oportunidad";
}
$outid=mysql_insert_id();
for($a=0;$a<=9;$a++){
$varname=$imagenes."imagen".$a;
$ext="";
echo($varname."<br />".$_FILES[$varname]["name"]."<br /><br />");
if($_FILES[$varname]["name"]!=""){
if($_FILES[$varname]["type"]=="image/gif"){ $ext="gif"; }
if($_FILES[$varname]["type"]=="image/jpeg"){ $ext="jpg"; }
if($_FILES[$varname]["type"]=="image/pjpeg"){ $ext="jpg"; }
if($_FILES[$varname]["type"]=="image/png"){ $ext="png"; }
if($ext!=""){
if($ext=="gif"){ $src_img=imagecreatefromgif($_FILES[$varname]["tmp_name"]); }
if($ext=="jpg"){ $src_img=imagecreatefromjpeg($_FILES[$varname]["tmp_name"]); }
if($ext=="png"){ $src_img=imagecreatefrompng($_FILES[$varname]["tmp_name"]); }
$orx=imageSX($src_img);
$ory=imageSY($src_img);
if($orx>$ory){
$thx=300;
$thx2=150;
$bix=480;
$big="x";
}
if($ory>$orx){
$thy=224;
$thy2=112;
$biy=300;
$big="y";
}
if($big=="x"){
$thy=$ory*$thx/$orx;
$thy2=$ory*$thx2/$orx;
$biy=$ory*$bix/$orx;
if($orx<$bix){ $bix=$orx; $biy=$ory; }
}
if($big=="y"){
$thx=$orx*$thy/$ory;
$thx2=$orx*$thy2/$ory;
$bix=$orx*$biy/$ory;
if($ory<$biy){ $bix=$orx; $biy=$ory; }
}
$thumbnail=ImageCreateTrueColor($thx,$thy);
imagecopyresampled($thumbnail,$src_img,0,0,0,0,$thx,$thy,$orx,$ory);
$nombre=md5(rand(3000,9999)+mktime());
imagejpeg($thumbnail,"../imagenes/th_".$nombre.".jpg");
imagedestroy($thumbnail);
$thumbnail=ImageCreateTrueColor($thx2,$thy2);
imagecopyresampled($thumbnail,$src_img,0,0,0,0,$thx2,$thy2,$orx,$ory);
imagejpeg($thumbnail,"../imagenes/th2_".$nombre.".jpg");
imagedestroy($thumbnail);
$bigimage=ImageCreateTrueColor($bix,$biy);
imagecopyresampled($bigimage,$src_img,0,0,0,0,$bix,$biy,$orx,$ory);
imagejpeg($bigimage,"../imagenes/".$nombre.".jpg");
imagedestroy($bigimage);
imagedestroy($src_img);
$sql="INSERT INTO imagenes (id,propiedad,imagen) VALUES ('','".$outid."','".$nombre."')";
$result=mysql_query($sql);
}
}
}
}
it receives the name from here
<input type=file name="preventaimagen0">
but the image name is not sending, any one have an idea why?
the image im sending is test.jpg
when i submit the form, with previously selected
<option value="1">Casa</option>
it shows me this when i do the echo on the do.php file
casasimagen0 test.jpg
but with others, for example
<option value="6">Preventa</option>
or any other is the same no image name
preventaimagen0
please help is really urgent


Sign In
Create Account

Back to top









