Ver Mensaje Individual
  #3 (permalink)  
Antiguo 30/08/2007, 09:30
javy
 
Fecha de Ingreso: septiembre-2002
Mensajes: 153
Antigüedad: 21 años, 7 meses
Puntos: 1
Re: Problema al mandar formulario y frames

Hola BONEZ.

Aquí les dejo el código, aver que tal:

1) PÁGINA PRINCIPAL:

<html>
<head>
<META HTTP-EQUIV="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<?php
//CONECTANDO CON LA BASE DE DATOS
require_once("../incluye/config.php");
require_once("../incluye/funciones.php");
//CONECTAR A LA BASE DE DATOS
$cnx = conectar ();

//SI EL FORMULARIO HA SIDO ENVIADO, SE EDITA EL REGISTRO
if(isset($_POST['submit'])){
{
if (is_uploaded_file($_FILES['imagen']['tmp_name'])) {
// REVISAR QUE SEA JPG
if ($_FILES['imagen']['type'] == "image/jpeg" || $_FILES['imagen']['type'] == "image/pjpeg"){
// NUEVO NOMBRE PARA LA IMAGEN
// AL PONER time(). DELANTE, AADIR LA FECHA AL NOMBRE DE LA IMAGEN.
/* SI SE QUITA, DEJAR EL NOMBRE COMO EST. AS SE PUEDEN DUPLICAR DATOS EN LA
BASE DE DATOS, PUDIENDO DAR ERRORES */
$nuevoNombre = time().$_FILES['imagen']['name'];
// METER LA IMAGEN DONDE SE QUIERE QUE EST
move_uploaded_file($_FILES['imagen']['tmp_name'], "../imagenes/productos/$nuevoNombre");
// OBTENER LA INFORMACIN
$data = GetImageSize("../imagenes/productos/$nuevoNombre");

$sql = "INSERT INTO lista_productos SET ";
$sql .= "listaproductos ='".$_POST['listaproductos']."',";
$sql .= "categoriasid ='".$_POST['categoriasid']."',";
$sql .= "subcategoriasid ='".$_POST['subcategoriasid']."',";
$sql .= "fabricantesid ='".$_POST['fabricantesid']."',";
$sql .= "precioproductos ='".$_POST['precioproductos']."',";
$sql .= "caracteristicaproductos ='".$_POST['caracteristicaproductos']."',";
$sql .= "fotoproductos='../imagenes/productos/$nuevoNombre'";
$res = mysql_query($sql) or die(mysql_error());
echo "Registro actualizado.<br><br><form action='lista_productos.php' method='post'><input name='entrar' type='submit' id='entrar' value='REGRESAR' onClick='submit()' /></form>";
mysql_close($idcnx);
exit;
}
}
}
}

//CONECTANDO CON LA BASE DE DATOS
require_once("../incluye/config_javy.php");
require_once("../incluye/funciones.php");

//CONECTAR A LA BASE DE DATOS
$cnx = conectar ();
?><body>
<table border="1" cellpadding="0" cellspacing="0">
<form enctype="multipart/form-data" name="form1" method="post" action="<?echo $_SERVER['PHP_SELF'];?>">
<tr>
<td colspan="2"><table width="500" height="300" border="1" cellpadding="4" cellspacing="4">
<tr>
<td valign="top"><iframe src="pag2.php" width="100%" height="100%" align="left" scrolling="no"></iframe></td>
</tr>
</table></td>

</tr>
<tr>
<td colspan="2"><table border="1" cellpadding="4" cellspacing="4">
<tr>
<td>Texto para el Nuevo PRODUCTO:</td>
</tr>
<tr>
<td><textarea name="listaproductos" cols="100" rows="3" id="listaproductos"><? echo $fila['listaproductos'];?></textarea></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2"><table border="1" cellpadding="4" cellspacing="4">
<tr>
<td>Texto para CARACTERÍSTICAS:</td>
</tr>
<tr>
<td><textarea name="caracteristicaproductos" cols="100" rows="30" id="caracteristicaproductos"><? echo $fila['caracteristicaproductos'];?></textarea></td>
</tr>
</table></td>
</tr>
<tr>
<td>Foto:</td>
<td><input type="hidden" name="MAX_FILE_SIZE" value="100000">
<input name="imagen" type="file" size="100"></td>
</tr>
<tr>
<td colspan="2" align="right"><input type="submit" name="submit" value="enviar"></td>
</tr>
</form>
<form action="lista_productos.php" method="post">
<tr>
<td colspan="2"><input name="entrar" type="submit" id="entrar" value="<---" onClick="submit()"></td>
</tr>
</form>
</table>
</body>
</html>


2) Página que está dentro del FRAME (en color rojo): pag2.php

<html>
<head>
<META HTTP-EQUIV="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<table border="1" cellpadding="4" cellspacing="4">
<tr>
<td colspan="2" class='texto_buscador'>Seleccionar primero una Categoría y una Subcategoría:</td>
</tr>
<tr>
<td>
<?php
//CONECTANDO CON LA BASE DE DATOS
require_once("../incluye/config.php");
require_once("../incluye/funciones.php");
?>
<?php
// SELECCIONANDO DE LA BASE DE DATOS PARA CATEGORIAS
mysql_select_db($DATABASE, $idcnx);

$query_CATEGORIAS = "SELECT * FROM categorias ORDER BY textocategorias ASC";
$CATEGORIAS = mysql_query($query_CATEGORIAS, $idcnx) or die(mysql_error());
$row_CATEGORIAS = mysql_fetch_assoc($CATEGORIAS);
$totalRows_CATEGORIAS = mysql_num_rows($CATEGORIAS);
//FIN DE SELECCIÓN

//SELECCIONANDO DE LA BASE DE DATOS PARA SUBCATEGORIAS
$colname_SUBCATEGORIAS = "-1";
if (isset($_POST['categoriasid'])) {
$colname_SUBCATEGORIAS = $_POST['categoriasid'];
}
mysql_select_db($DATABASE, $idcnx);

$query_SUBCATEGORIAS = sprintf("SELECT subcategoriasid, textosubcategorias FROM subcategorias WHERE categoriasid = '%s' ORDER BY textosubcategorias ASC", $colname_SUBCATEGORIAS);
$SUBCATEGORIAS = mysql_query($query_SUBCATEGORIAS, $idcnx) or die(mysql_error());
$row_SUBCATEGORIAS = mysql_fetch_assoc($SUBCATEGORIAS);
$totalRows_SUBCATEGORIAS = mysql_num_rows($SUBCATEGORIAS);
//FIN DE SELECCIÓN
?>
<form name="formulario0" method="post" action="">
<select name="categoriasid" id="categoriasid" onChange="submit()">
<option value="" <?php if (!(strcmp("", $_POST['categoriasid']))){echo "SELECTED";} ?>><?php
$numero_categorias = mysql_num_rows($CATEGORIAS);
?>Hay <?php echo "$numero_categorias"; ?> Categorías</option>
<?php
do {
?>
<option value="<?php echo $row_CATEGORIAS['categoriasid']?>"<?php if (!(strcmp($row_CATEGORIAS['categoriasid'], $_POST['categoriasid']))) {echo "SELECTED";} ?>><?php echo $row_CATEGORIAS['textocategorias']?></option>
<?php
} while ($row_CATEGORIAS = mysql_fetch_assoc($CATEGORIAS));
$rows = mysql_num_rows($CATEGORIAS);
if($rows > 0) {
mysql_data_seek($CATEGORIAS, 0);
$row_CATEGORIAS = mysql_fetch_assoc($CATEGORIAS);
}
?>
</select>
</form></td>
<td><form name="formulario1" action="" method="post">
<select name="subcategoriasid" id="subcategoriasid">
<option value="" <?php if (!(strcmp("", $_POST['subcategoriasid']))) {echo "SELECTED";} ?>><?php
$numero_subcategorias = mysql_num_rows($SUBCATEGORIAS);
?>Se han encontrado <?php echo "$numero_subcategorias"; ?> Subcategorías</option>
<?php
do {
?>
<option value="<?php echo $row_SUBCATEGORIAS['subcategoriasid']?>"<?php if (!(strcmp($row_SUBCATEGORIAS['subcategoriasid'], $_POST['subcategoriasid']))) {echo "SELECTED";} ?>><?php echo $row_SUBCATEGORIAS['textosubcategorias']?></option>
<?php
} while ($row_SUBCATEGORIAS = mysql_fetch_assoc($SUBCATEGORIAS));
$rows = mysql_num_rows($SUBCATEGORIAS);
if($rows > 0) {
mysql_data_seek($SUBCATEGORIAS, 0);
$row_SUBCATEGORIAS = mysql_fetch_assoc($SUBCATEGORIAS);
}
?>
</select>
</form></td>
</tr>
<tr>
<td colspan="2">Seleccionar un Fabricante:</td>
</tr>
<tr>
<td colspan="2">
<?php
//CONECTANDO... Y SELECCIONANDO DE LA BASE DE DATOS PARA FABRICANTES
require_once("../incluye/config.php");
require_once("../incluye/funciones.php");
$cnx = conectar();
$fabricantes = mysql_query("SELECT fabricantesid, textofabricantes FROM fabricantes ORDER BY textofabricantes");
?>
<form name="formulario2" action="resultado.php" method="post">
<select name="fabricantesid" id="fabricantesid" class='texto_buscador' onChange="enviar2();">
<option value=""><?php
$numero_fabricantes = mysql_num_rows($fabricantes);
?>Hay <?php echo "$numero_fabricantes"; ?> Fabricantes</option>
<?php
while ($fabricante = mysql_fetch_array($fabricantes)) {
$fabricantesid = $fabricante["fabricantesid"];
$fname = $fabricante["textofabricantes"];
echo("<option value='$fabricantesid'>$fname</option>\n");
}
?>
</select>
</form></td>
</tr>
<tr>
<td colspan="2">Introducir el Precio:</td>
</tr>
<tr valign="middle">
<td colspan="2"><?php
require_once("../incluye/config.php");
require_once("../incluye/funciones.php");
mysql_select_db($DATABASE, $idcnx);
?>
<form name="formulario3" action="" method="post">
<input name="precioproductos" type="text" id="precioproductos" size="20"> €
</form></td>
</tr>
</table>
</body>
</html>


Espero que no sea demasiado.

Gracias:

Javy