Ver Mensaje Individual
  #8 (permalink)  
Antiguo 19/10/2011, 07:30
ofertasdiarias
 
Fecha de Ingreso: marzo-2011
Mensajes: 115
Antigüedad: 13 años, 1 mes
Puntos: 0
Respuesta: problema con formulario, por favor

hola CesarHC gracias por tu ejemplo.

miren ahora eh logrado subir la imagen, pero a la hora de ver no me aparece les dejo los script para ver si alguien se da cuenta en que fallo. y tambien para alguna otra persona que le sirva.

esta es la base de datos :

Código MySQL:
Ver original
  1. CREATE TABLE IF NOT EXISTS `formulario` (
  2.   `id_rubro` int(11) NOT NULL AUTO_INCREMENT,
  3.   `seccion` varchar(255) NOT NULL,
  4.   `ubicacion` varchar(255) NOT NULL,
  5.   `precio` varchar(255) NOT NULL,
  6.   `simbolo` varchar(255) NOT NULL,
  7.   `Titulo` varchar(255) NOT NULL,
  8.   `Descripcion` varchar(255) NOT NULL,
  9.   `email` varchar(255) NOT NULL,
  10.   `telefono` varchar(255) NOT NULL,
  11.   `Imagen` varchar(255) NOT NULL,
  12.   PRIMARY KEY (`id_rubro`)

esta es la pagina de formulario.php

Código PHP:
Ver original
  1. <?php virtual('/Connections/anuncios.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6.   if (PHP_VERSION < 6) {
  7.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8.   }
  9.  
  10.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  11.  
  12.   switch ($theType) {
  13.     case "text":
  14.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  15.       break;    
  16.     case "long":
  17.     case "int":
  18.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  19.       break;
  20.     case "double":
  21.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  22.       break;
  23.     case "date":
  24.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  25.       break;
  26.     case "defined":
  27.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  28.       break;
  29.   }
  30.   return $theValue;
  31. }
  32. }
  33.  
  34. $editFormAction = $_SERVER['PHP_SELF'];
  35. if (isset($_SERVER['QUERY_STRING'])) {
  36.   $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  37. }
  38.  
  39. if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  40.         $tipo_prod = $_POST["MM_insert"];
  41.  
  42.     //Guardar imagen
  43.     if(is_uploaded_file($_FILES['fleImagen']['tmp_name'])) { // verifica haya sido cargado el archivo
  44.     $ruta= "/images/$tipo_prod/".$_FILES['fleImagen']['name'];
  45.     move_uploaded_file($_FILES['fleImagen']['tmp_name'], $ruta);
  46.     }
  47.   $insertSQL = sprintf("INSERT INTO formulario (id_rubro, seccion, ubicacion, precio, simbolo, Titulo, Descripcion, email, telefono, Imagen) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
  48.                        GetSQLValueString($_POST['id_rubro'], "int"),
  49.                        GetSQLValueString($_POST['txtseccion'], "text"),
  50.                        GetSQLValueString($_POST['txtubicacion'], "text"),
  51.                        GetSQLValueString($_POST['txtprecio'], "text"),
  52.                        GetSQLValueString($_POST['txtSimbolo'], "text"),
  53.                        GetSQLValueString($_POST['txtTitulo'], "text"),
  54.                        GetSQLValueString($_POST['txtDescripcion'], "text"),
  55.                        GetSQLValueString($_POST['txtemail'], "text"),
  56.                        GetSQLValueString($_POST['txttelefono'], "text"),
  57.                        GetSQLValueString($ruta, "text"));
  58.  
  59.   mysql_select_db($database_anuncios, $anuncios);
  60.   $Result1 = mysql_query($insertSQL, $anuncios) or die(mysql_error());
  61.  
  62.   $insertGoTo = "/ingreso_exitoso.php";
  63.   if (isset($_SERVER['QUERY_STRING'])) {
  64.     $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
  65.     $insertGoTo .= $_SERVER['QUERY_STRING'];
  66.   }
  67.   header(sprintf("Location: %s", $insertGoTo));
  68. }
  69.  
  70. ?>
  71.  
  72. <form action="catalogo.php" method="POST" enctype="multipart/form-data" name="form1">
  73.   <table align="center">
  74.     <tr valign="baseline">
  75.       <td nowrap align="right">Seccion:</td>
  76.       <td><select name="txtseccion" id="txtseccion">
  77.         <option value="Seleccionar" selected>Seleccionar</option>
  78.         <option value="Accesorios">Accesorios</option>
  79.         <option value="Camisetas">Camisetas</option>
  80.       </select></td>
  81.     </tr>
  82.     <tr valign="baseline">
  83.       <td nowrap align="right">Ubicacion:</td>
  84.       <td><select name="txtubicacion" id="txtubicacion">
  85.         <option value="Seleccionar">Seleccionar</option>
  86.         <option value="Montevideo">Montevideo</option>
  87.         <option value="Maldonado">Maldonado</option>
  88.       </select></td>
  89.     </tr>
  90.     <tr valign="baseline">
  91.       <td nowrap align="right">Precio:</td>
  92.       <td><input name="txtprecio" type="text" id="txtprecio" value="" size="32"></td>
  93.     </tr>
  94.     <tr valign="baseline">
  95.       <td nowrap align="right">Moneda:</td>
  96.       <td><select name="txtsimbolo" id="txtsimbolo">
  97.         <option value="Seleccionar">Seleccionar</option>
  98.         <option value="Pesos">Pesos</option>
  99.         <option value="Dolares">Dolares</option>
  100.       </select></td>
  101.     </tr>
  102.     <tr valign="baseline">
  103.       <td nowrap align="right">Titulo:</td>
  104.       <td><input name="txtTitulo" type="text" id="txtTitulo" value="" size="32"></td>
  105.     </tr>
  106.     <tr valign="baseline">
  107.       <td nowrap align="right" valign="top">Descripcion:</td>
  108.       <td><textarea name="txtDescripcion" cols="50" rows="5" id="txtDescripcion"></textarea></td>
  109.     </tr>
  110.     <tr valign="baseline">
  111.       <td nowrap align="right">Email:</td>
  112.       <td><input name="txtemail" type="text" id="txtemail" value="" size="32"></td>
  113.     </tr>
  114.     <tr valign="baseline">
  115.       <td nowrap align="right">Telefono:</td>
  116.       <td><input name="txttelefono" type="text" id="txttelefono" value="" size="32"></td>
  117.     </tr>
  118.     <tr valign="baseline">
  119.       <td nowrap align="right">Imagen:</td>
  120.       <td><input name="fleImagen" type="file" id="fleImagen" value="" size="32" /></td>
  121.     </tr>
  122.     <tr valign="baseline">
  123.       <td nowrap align="right">&nbsp;</td>
  124.       <td><input type="submit" value="Insertar registro"> <input type="reset" name="button" id="button" value="Restablecer"></td>
  125.     </tr>
  126.   </table>
  127.   <input type="hidden" name="id_rubro" value="">
  128.   <input type="hidden" name="MM_insert" value="form1">
  129. </form>
  130. <p>&nbsp;</p>

y esta es la de catalogo.php

Código PHP:
Ver original
  1. <?php virtual('/Connections/anuncios.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6.   if (PHP_VERSION < 6) {
  7.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8.   }
  9.  
  10.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  11.  
  12.   switch ($theType) {
  13.     case "text":
  14.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  15.       break;    
  16.     case "long":
  17.     case "int":
  18.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  19.       break;
  20.     case "double":
  21.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  22.       break;
  23.     case "date":
  24.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  25.       break;
  26.     case "defined":
  27.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  28.       break;
  29.   }
  30.   return $theValue;
  31. }
  32. }
  33.  
  34. $maxRows_catalogo_imag = 10;
  35. $pageNum_catalogo_imag = 0;
  36. if (isset($_GET['pageNum_catalogo_imag'])) {
  37.   $pageNum_catalogo_imag = $_GET['pageNum_catalogo_imag'];
  38. }
  39. $startRow_catalogo_imag = $pageNum_catalogo_imag * $maxRows_catalogo_imag;
  40.  
  41. mysql_select_db($database_anuncios, $anuncios);
  42. $query_catalogo_imag = "SELECT * FROM formulario";
  43. $query_limit_catalogo_imag = sprintf("%s LIMIT %d, %d", $query_catalogo_imag, $startRow_catalogo_imag, $maxRows_catalogo_imag);
  44. $catalogo_imag = mysql_query($query_limit_catalogo_imag, $anuncios) or die(mysql_error());
  45. $row_catalogo_imag = mysql_fetch_assoc($catalogo_imag);
  46.  
  47. if (isset($_GET['totalRows_catalogo_imag'])) {
  48.   $totalRows_catalogo_imag = $_GET['totalRows_catalogo_imag'];
  49. } else {
  50.   $all_catalogo_imag = mysql_query($query_catalogo_imag);
  51.   $totalRows_catalogo_imag = mysql_num_rows($all_catalogo_imag);
  52. }
  53. $totalPages_catalogo_imag = ceil($totalRows_catalogo_imag/$maxRows_catalogo_imag)-1;
  54. ?>
  55. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  56. <html xmlns="http://www.w3.org/1999/xhtml">
  57. <head>
  58. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  59. <title>Documento sin título</title>
  60. </head>
  61.  
  62. <body>
  63. <table border="0">
  64.   <tr>
  65.     <td>id_rubro</td>
  66.     <td>seccion</td>
  67.     <td>ubicacion</td>
  68.     <td>precio</td>
  69.     <td>simbolo</td>
  70.     <td>Titulo</td>
  71.     <td>Descripcion</td>
  72.     <td>email</td>
  73.     <td>telefono</td>
  74.     <td>Imagen</td>
  75.   </tr>
  76.   <?php do { ?>
  77.     <tr>
  78.       <td><?php echo $row_catalogo_imag['id_rubro']; ?></td>
  79.       <td><?php echo $row_catalogo_imag['seccion']; ?></td>
  80.       <td><?php echo $row_catalogo_imag['ubicacion']; ?></td>
  81.       <td><?php echo $row_catalogo_imag['precio']; ?></td>
  82.       <td><img "<?php echo $row_catalogo_imag['Imagen']; ?> " /></td>    
  83.       <td><?php echo $row_catalogo_imag['Titulo']; ?></td>
  84.       <td><?php echo $row_catalogo_imag['Descripcion']; ?></td>
  85.       <td><?php echo $row_catalogo_imag['email']; ?></td>
  86.       <td><?php echo $row_catalogo_imag['telefono']; ?></td>
  87.       <td><?php echo $row_catalogo_imag['simbolo']; ?> </td>
  88.     </tr>
  89.     <?php } while ($row_catalogo_imag = mysql_fetch_assoc($catalogo_imag)); ?>
  90. </table>
  91. </body>
  92. </html>
  93. <?php
  94. mysql_free_result($catalogo_imag);
  95. ?>
  96. <img src=" " />

yo no me doy cuenta pero si alguien lo ve desde ya muchas gracias!!!