pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

PHP paste-bin - collaborative debugging tool View Help


Posted by eder on Wed 2nd May 18:54
download | new post

  1. <?php
  2. include("config.inc");
  3. $set=$_GET['set'];
  4. if ($set=="envio") {
  5.         //query para inserir os valores
  6.         $query = "INSERT INTO imoveis (tipo, bairros, valor, operacao, finalidade, fotos, descricao) VALUES ('$tipo', '$bairro', '$valor', '$operacao',
  7. '$finalidade', '$numfotos','$descricao')";
  8.         $inserindo = mysql_query($query);
  9.         if($inserindo) {
  10.                 $selecao = "SELECT id FROM imoveis"; //pegando o id da insercao
  11.                 $numeroid=mysql_query($selecao);
  12.                 $id = mysql_num_rows($numeroid);
  13.                 echo "<p align='center'>Dados inseridos com sucesso! Número de Identificação: $id.</p><br><br>";
  14.         }       else
  15.                         echo ("Erro, impossível cadastrar o imóvel, tente mais tarde!");
  16.                 if($numfotos > "0") {
  17.                         print '<form name="fotos" method="post" action="fotosload.php?enviar=ok" enctype="multipart/form-data">';
  18.                         print '<input type="hidden" name="id2" value="'.$id.'">';
  19.                 for ($i=1; $i<=$numfotos; $i++)
  20.                         print '<p align="center">Foto' .$i. '<input type="file" name="foto[]" value="" /><br>';   
  21.                 print '<input type="Submit" name="enviar" value="Enviar fotos"></p></form>';
  22.                 }
  23.                 echo "<p align='center'><a href='gravaimovel.php'>Fazer outro cadastro</a></p>";
  24.                 echo "<p align='center'><a href='sair.php'>Fechar esta sessão</a></p>";
  25.                                
  26.         }
  27.                 else {
  28.  
  29. ?>
  30. <style type="text/css">
  31. <!--
  32. h1,h2,h3,h4,h5,h6 {
  33.         font-family: Verdana, Arial, Helvetica, sans-serif;
  34. }
  35. .style3 {font-size: 18px}
  36. .style5 {
  37.         font-size: 16px;
  38.         font-family: Verdana, Arial, Helvetica, sans-serif;
  39.         color: #990000;
  40. }
  41. -->
  42. </style>
  43.  
  44. <ul>
  45. <table width="401">
  46.   <tr>
  47.     <th width="393" align="center" scope="col"><span class="style5">Sistema de Atualiza&ccedil;&atilde;o - WBImoveis.com.br</span></th>
  48.   </tr>
  49. </table>
  50. <br />
  51. <table width="395" border="1">
  52.   <tr>
  53.     <th width="385" height="119" align="left" bordercolor="#990000" scope="col">
  54.         <form name="cadastro" action="gravaimovel.php?set=envio" method="post">
  55.         <p>Tipo de im&oacute;vel:
  56.                          <select name="tipo" id="tipo" tabindex="1">
  57.                            <option value="vazio">Tipo de im&oacute;vel</option>
  58.               <option value="apartamento">Apartamento</option>
  59.               <option value="casa">Casa</option>
  60.               <option value="predcomercial">Pr&eacute;dio comercial</option>
  61.               <option value="galpao">Galp&atilde;o</option>
  62.               <option value="granja">Granja</option>
  63.               <option value="fazenda">Fazenda</option>
  64.               <option value="flat">Flat</option>
  65.               <option value="terreno">Terreno</option>
  66.               <option value="salacomercial">Sala com&eacute;rcial</option>
  67.               </select></p>
  68.         <p>Bairro:
  69.                         <select name="bairro" tabindex="2">
  70.                         <?php //pegando a lista de bairros no banco de dados
  71.                         $query2 = "SELECT bairro FROM bairros";
  72.                         $consulta = mysql_query($query2);
  73.                         while($resultado = mysql_fetch_array($consulta))
  74.                           print "<option value=".$resultado['bairro'].">".$resultado['bairro']."</option>";
  75.                         ?>
  76.             </select></p>
  77.         <p>Pre&ccedil;o(n&uacute;meros, pontos e v&iacute;rgula):
  78.           R$
  79.           <input name="valor" type="text" id="valor" value="00,00" size="18" tabindex="3"/>
  80.         </p>
  81.         <p>O im&oacute;vel est&aacute; dispon&iacute;vel para
  82.           <select name="operacao" id="operacao" tabindex="4">
  83.             <option value="comprar" selected="selected">Venda</option>
  84.             <option value="alugar">Aluguel</option>
  85.             </select></p>
  86.         <p>A caracter&iacute;stica do im&oacute;vel &eacute;
  87.           <select name="finalidade" id="finalidade" tabindex="5">
  88.             <option value="residencial" selected="selected">Residencial</option>
  89.             <option value="comercial">Comercial</option>
  90.           </select>
  91.         </p>
  92.         <p>Descri&ccedil;&atilde;o<br /><textarea name="descricao" id="descricao" rows="4" cols="50" tabindex="6">Exemplo:
  93. Casa maravilhosa com 4 cômodos, 2 banheiros, cozinha com lavabo, sala para 2 ambientes, garagem para 4 carros, etc.</textarea></p>
  94.         <p>Digite a quantidade de fotos do im&oacute;vel. Caso n&atilde;o haja foto, deixe valor zero:
  95.           <input name="numfotos" type="text" id="numfotos" value="0" size="4" maxlength="1" />
  96.           </p>
  97.         <p align="center">
  98.           <input name="enviar" type="submit" id="enviar" value="Gravar registro" tabindex="7"/>
  99.         </p>
  100.         </form>      </th>
  101.     </tr>
  102. </table>
  103. </ul>
  104. <?php
  105. }
  106. ?>
  107. <?php
  108. include("config2.inc");
  109. if ($_GET['enviar']=="ok") {
  110.  
  111.         $Conectar = ftp_connect($ftp_Host);
  112.         ftp_login($Conectar, $ftp_User, $ftp_Senha);
  113.         for ($i=1;$i<=$numfotos2;$i++) {
  114.         foreach($_FILES['foto']['name'] as $key => $name) {
  115.                 $Caminho = $_FILES['foto']['tmp_name'][$key];
  116.                 $Destino = $ftp_Root.$_POST['id2'].$key;
  117.                 $status = ftp_put($Conectar, $Destino, $Caminho, FTP_BINARY);
  118.                         if($status) {
  119.                         echo "<p align='center'>Foto enviada com sucesso!</p>";
  120.                 } else {
  121.                         echo "<p align='center'>O envio da foto falhou! Tente novamente</p>";
  122.                 }
  123.         }
  124.         }
  125.         ftp_close($Conectar);
  126.  
  127.         /* for ($i=1;$i<=$_POST['numfotos2'];$i++) {
  128.                 $sourcefile = $_POST["foto".$_POST['id2'].$i;
  129.                 $Filename = $ftp_Root .  $sourcefile;
  130.                 $status = ftp_put($Conectar, $Filename, $sourcefile, FTP_BINARY);
  131.                 if($status) {
  132.                         echo "<p align='center'>Foto $i enviada com sucesso!</p>";
  133.                 } else {
  134.                         echo "<p align='center'>O envio da foto $i falhou! Tente novamente</p>";
  135.                 }
  136.         } */
  137. }
  138.  else
  139.  {
  140.          echo "<br><br><br><p align='center'>Erro, você não selecionou todas as fotos corretamente!</p>";
  141.  }
  142. ?>
  143. <p align="center">
  144. <a href="javascript:window.close()">Fechar</a></p>

Submit a correction or amendment below. (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Use syntax highlighting

To highlight particular lines, prefix each line with @@
:
:
Remember my settings