Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/12/2009, 18:26
federic1972
 
Fecha de Ingreso: octubre-2008
Mensajes: 24
Antigüedad: 15 años, 6 meses
Puntos: 0
Ayuda con el ultimo paso por favor

tengo esta pagina, que conecta un formulario con la base de datos, para recuperar luego los datos, el tema es que no se en que parte de la pagina pongo el codigo del file upload..... o mejor dicho como lo anexo para que funcione...

<?php require_once('Connections/anuncios.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

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")) {
$insertSQL = sprintf("INSERT INTO anuncio (titulo, descripcion, provincia, condicion, foto1, foto2) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['titulo'], "text"),
GetSQLValueString($_POST['descripcion'], "text"),
GetSQLValueString($_POST['provincia'], "text"),
GetSQLValueString($_POST['condicion'], "text"),
GetSQLValueString($_POST['foto1'], "text"),
GetSQLValueString($_POST['foto2'], "text"));

mysql_select_db($database_anuncios, $anuncios);
$Result1 = mysql_query($insertSQL, $anuncios) or die(mysql_error());

$insertGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_anuncios, $anuncios);
$query_formulario = "SELECT * FROM anuncio";
$formulario = mysql_query($query_formulario, $anuncios) or die(mysql_error());
$row_formulario = mysql_fetch_assoc($formulario);
$totalRows_formulario = mysql_num_rows($formulario);
?>

<!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=utf-8" />
<title>mi pagina web</title>
<style type="text/css">
<!--
body {
margin-top: 0px;
}
-->
</style>
<link href="estilo_misitio.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.Estilo1 {color: #FF0000}
-->
</style>
<script type="text/javascript">
<!--
function MM_validateForm() { //v4.0
if (document.getElementById){
var i,p,q,nm,test,num,min,max,errors='',args=MM_valida teForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
} }
//-->
</script>
</head>

<body>
<table width="80%" align="center" cellpadding="0" cellspacing="0">
<tr>
<td scope="col"><div class="cabecera">misitio web</div></td>
</tr>
<tr>
<td><div class="logo">coolface<span class="Estilo1">yo</span>.com / <span class="Estilo1">todo España</span></div></td>
</tr>
<tr>
<td><div class="barra"></div></td>
</tr>
<tr>
<td><div class="buscador">ver consulta</div></td>
</tr>
<tr>
<td><br />
<form action="<?php echo $editFormAction; ?>" method="post" enctype="multipart/form-data" name="form1" id="form1">
<table align="center" class="tabla_anuncios">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Titulo:</td>
<td><input name="titulo" type="text" id="titulo" onblur="MM_validateForm('titulo','','R');return document.MM_returnValue" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right" valign="top">Descripcion:</td>
<td><textarea name="descripcion" cols="50" rows="5"></textarea> </td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Provincia:</td>
<td><input type="text" name="provincia" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Condicion:</td>
<td><input type="text" name="condicion" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Foto1:</td>
<td><label>
<input type="file" name="foto1" id="foto1" />
</label></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Foto2:</td>
<td><label>
<input type="file" name="foto2" id="foto2" />
</label></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">&nbsp;</td>
<td><input type="submit" value="Insertar registro" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p>&nbsp;</p>
<br /></td>
</tr>
<tr>
<td>Sugerencias</td>
</tr>
<tr>
<td>Pie de pagina</td>
</tr>
</table>

<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($formulario);
?>



espero me ayuden gracias desde ya.