o esta segunda opción??,
perdón por mi pesadez, pero soy bastante novato.
Código PHP:
Ver original<?php require_once('Connections/con_imag.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
}
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ?
intval($theValue) : "NULL"; break;
case "double":
$theValue = ($theValue != "") ?
doubleval($theValue) : "NULL"; break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); }
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $tipo_prod = $_POST["lstTipo"];
//Guardar imagen
if(is_uploaded_file($_FILES['fleImagen']['tmp_name'])) { // verifica haya sido cargado el archivo $ruta= "images/$tipo_prod/".$_FILES['fleImagen']['name'];
$insertSQL = sprintf("INSERT INTO contactos (Referencia, telefono, Imagen, Tipo, Precio, Nombreimg, Descripcion) VALUES (%s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['txtReferencia'], "int"),
GetSQLValueString($_POST['txttelefono'], "text"),
GetSQLValueString($ruta, "text"),
GetSQLValueString($_POST['lstTipo'], "text"),
GetSQLValueString($_POST['txtPrecio'], "double"),
GetSQLValueString($_POST['txtNombreimg'], "text"),
GetSQLValueString($_POST['txtDescripcion'], "text"));
}
$insertGoTo = "ingreso_exitoso.php";
if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ?
"&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING'];
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
</head>
<body>
<form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form1" id="form1">
<table width="590" border="1">
<tr>
<td width="208"> </td>
<td width="366"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2" bgcolor="#71AAE5"><div align="center"> <strong><em>Datos de acceso a su/s anuncio/s.</em></strong></div></td>
</tr>
<tr>
<td><strong>Teléfono:</strong></td>
<td colspan="2"><label for="txttelefono"></label>
<input type="text" name="txttelefono" id="txttelefono" /></td>
- </tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td width="208"><strong>Referencia:</strong></td>
<td width="366"><label for="txtReferencia"></label>
<input name="txtReferencia" type="text" id="txtReferencia" value="ref. 2654112445" readonly="readonly" /></td>
</tr>
<tr>
<td><strong>Imagen:</strong></td>
<td><label for="fleImagen"></label>
<input type="file" name="fleImagen" id="fleImagen" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td><strong>Nombre:</strong></td>
<td><label for="txtNombreimg"></label>
<input type="text" name="txtNombreimg" id="txtNombreimg" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td><strong>Tipo:</strong></td>
<td><label for="lstTipo"></label>
<select name="lstTipo" id="lstTipo">
<option value="camisetas" selected="selected">Camisetas</option>
<option value="accesorios">Accesorios</option>
</select></td>
</tr>
<tr>
<td><strong>Precio:</strong></td>
<td><label for="txtPrecio"></label>
<input type="text" name="txtPrecio" id="txtPrecio" /></td>
</tr>
<tr>
<td><strong>Descripción:</strong></td>
<td><label for="txtDescripcion"></label>
<textarea name="txtDescripcion" id="txtDescripcion" cols="45" rows="5"></textarea></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
<p>
<input type="submit" name="button" id="button" value="Enviar" />
</p>
<input type="hidden" name="MM_insert" value="form1" />
</form>
</body>
</html>