Muchas gracias por tu ayuda, he probado esto y no me funciona. El codigo es este, si tiene algun error por favor digamelo:
Código PHP:
<?php
require_once($_SERVER["DOCUMENT_ROOT"]."/funciones.php");
if($id_usuario){
if($id_usuario!=1){
mysql_query("update descargas set descargado=descargado+1 where id='$id'");
}
$result=mysql_query("select * from descargas where id=$id limit 1");
$row=mysql_fetch_array($result);
$enlace=$row["direccion"];
header ("Content-Disposition: attachment; filename=descarga_".$enlace."\n\n");
header ("Content-Type: application/octet-stream");
header ("Content-Length: ".filesize($enlace));
readfile($enlace);
}else{
header("location: /mensajes.php?id=9");
}
?>