Vale... estoy de acuerdo en que el uso de variables SESSION es preferible que pasarlas por URL, apenas resuelva este pequeñin, las paso toditas por SESSION... prometido!!!
Ahora, quieres el código completo, no cabe!!!: (ojo, no todo el código es hecho por mi, aprte del trabajo estaba empezado... eso es lo que me duele, estar leyendo un código ajeno, ahí medio lo estoy "arreglando")
frame central = medio5.php
frame izquierdo = barrafotos.php (obviado por lo largo)
frame derecho = detallefoto.php
frame central:
Código PHP:
<?php
include("../pages/includes/funciones.php");
session_start();
$album=$_REQUEST['album'];
$ci=$_REQUEST['ci'];
$carpeta=$_REQUEST['c'];
$sc=$_REQUEST['sc'];
$cod=$_REQUEST['cod'];
$foto=$_REQUEST['f'];
$ses=$_REQUEST['s'];
if ($_REQUEST['usr']){ $_SESSION['usuario']=$_REQUEST['usr']; }
else { $usuario=$_SESSION['usuario']; }
if ($_REQUEST['cla']) {
$_SESSION['clave']=$_REQUEST['cla'];
$clave=$_SESSION['clave']; }
if ($priv==0) { $privado=true; }
else { $privado=false; }
$r_a=ejecutar("select album.*,scategorias.scategoria from
scategorias,album where
album.id_album=$album and
album.id_scategoria=scategorias.id_scategoria and
album.activar=1");
$f_a=pg_fetch_array($r_a,NULL,PGSQL_ASSOC);
$sc=$f_a[id_scategoria];
list($ano,$mes,$dia)=split("-",$f_a[fecha],3);
?>
Código HTML:
<html>
<head>
<script LANGUAGE="JavaScript">
function enviar(){ document.c.submit(); }
function afoto(){
window.open('privado.php?cod=<?php echo $cod ?>&usuario=<?php echo $usuario ?>&sc=<?php echo $sc; ?>&c=<?php echo $carpeta; ?>',"Privado","width=350,height=150,scrollbars=NO,left=350,top=30 0");
}
function consultar(){
parent.izq.location.href=('barrafotos1.php?usuario=<?php echo $usuario; ?>&c=<?php echo $carpeta; ?>&sc=<?php echo $sc; ?>&album=<?php echo $album; ?>&v=<?php echo $val="1" ?>');
}
function asesion(){
if (document.iniciar.usr.value == '') { alert ('Nick vacío'); }
else {
if(document.iniciar.cla.value == '') { alert ('Contraseña vacía'); }
else {
document.iniciar.submit();
top.izq.location='barrafotos1.php?ci=<?php echo $ci; ?>&c=<?php echo $carpeta; ?>&sc=<?php echo $sc; ?>&album=<?php echo $album; ?>';
top.der.location='detallefoto1.php?f=<?php echo $foto; ?>&c=<?php echo $carpeta; ?>&sc=<?php echo $sc; ?>&album=<?php echo $album; ?>&cod=<?php echo $cod; ?>&s=<?php echo $_REQUEST['s']; ?>';
}
}
return null;
}
function fsesion() {
<?php session_unset(); ?>
top.location.href="galeriapers.php";
}
</script>
</head>
<body>
<table>
<tr>
<?php
$sesion=$_REQUEST['s'];
if (empty($sesion)) { echo "Usuario: Invitado<br>Local: $f_a[scategoria]<br>Foto Nº: $cod"; }
else {
session_start();
$cod=$_REQUEST['cod'];
if ($_REQUEST['usr']){
$_SESSION['usuario']=$_REQUEST['usr'];
$usuario=$_SESSION['usuario'];
} else {
$usuario=$_SESSION['usuario'];
}
echo "Usuario: $usuario<br>clave: $clave<br>Local: $f_a[scategoria]<br>Foto Nº: $cod";
}
?>
</td>
</tr>
<tr>
<?php
$clave_enc=md5($clave);
$q_consulta="SELECT * FROM album_personal WHERE usuario='$usuario' AND clave='$clave_enc' AND activo='1'";
$r_consulta=pg_query($q_consulta);
$c_consulta=pg_num_rows($r_consulta);
$f_consulta=pg_fetch_array($r_consulta);
if ($c_consulta==0) {
$sesion=session_id();
?>
<td>Iniciar Sesión
<form action="./medio5.php" method="POST" name="iniciar">
<table>
<tr><td>Nick:</td></tr>
<tr><TD>
<input type="text" name="usr">
<INPUT type="hidden" name="cod" value="<?php echo $cod; ?>">
<INPUT type="hidden" name="s" value="<?php echo $sesion; ?>">
<INPUT type="hidden" name="album" value="<?php echo $album; ?>">
<INPUT type="hidden" name="c" value="<?php echo $carpeta; ?>">
</TD>
<TR><TD>Contraseña:</TD>
</TR>
<TR><TD><INPUT type="password" name="cla"></TD>
<TD><a href="#" onclick="javascript: asesion();"><img src="../img-galeria/okbtn.gif"></a></TD><td></td>
</tr>
</table>
</form><?php } else { ?>
<td>Mi Album
<FORM name="guardar_foto" method="POST" target="_top">
<table>
<tr><td>Agregar Foto: </td>
<td><a href="#" onclick="javascript:afoto();"><img src="../img-galeria/okbtn.gif"> </a></td><td></td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td>
<FORM action="" name="guardar_amigo" method="POST" target="_top">
<table>
<tr><td>Agregar Amigo: </td>
<td><a href="javascript:aamigo();"><img src="../img-galeria/okbtn.gif" ></a></td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td>
<FORM name="consultar" target="_top">
<table>
<tr><td>Consultar Mi Album: </td>
<td><a href="javascript:consultar();"><img src="../img-galeria/okbtn.gif"> </a></td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td>
<FORM name="fsesion" method="POST" target="_top">
<table>
<tr><td>Finalizar Sesión: </td>
<td><a href="javascript:fsesion();"><img src="../img-galeria/okbtn.gif"></a></td> </tr>
</table>
</form>
</td>
<?php } ?>
</tr>
</table>
</body>
</html>
frame derecho:
Código PHP:
<?php
include ("../pages/includes/funciones.php");
session_start();
?>
<html>
<?php
$album=$_REQUEST[album];
$sc=$_REQUEST[sc];
$c=$_REQUEST[c];
$cod=$_REQUEST[cod];
$f=$_REQUEST[f];
$q_f="select * from fotos where id_album='$album' and activar=1 order by numero asc";
$r_f=pg_query($q_f);
session_start();
$usuario=$_SESSION['usuario'];
$clave=$_SESSION['clave'];
$num=pg_num_rows($r_f);
for($j=0;$j<$num;$j++){
$f_ids=pg_fetch_array($r_f,NULL,PGSQL_ASSOC);
$id[$j]=$f_ids[id_foto];
$img[$j]=$f_ids[img];
}
for($i=0;$i<$num;$i++){
if($cod==$id[$i]){
$ant=$id[$i-1];
$sig=$id[$i+1];
if(!empty($ant)){
$ope=$i-1;
$anterior="medio5.php?album=$album&f=$img[$ope]&sc=$sc&c=$c&cod=$ant";$_SESSION['usuario'];
$ant="detallefoto1.php?album=$album&f=$img[$ope]&sc=$sc&c=$c&cod=$ant";
}else
$ant="";
if(!empty($sig)){
$ope=$i+1;
$siguiente="medio5.php?album=$album&f=$img[$ope]&sc=$sc&c=$c&cod=$sig";$_SESSION['usuario'];
$sig="detallefoto1.php?album=$album&f=$img[$ope]&sc=$sc&c=$c&cod=$sig";
}else $sig="";
}
}
?>
<body>
<?php
echo "Usuario: ".$usuario.$clave;
$archivo="../../fotos/$sc/$c/$f";
if(file_exists($archivo)&&!empty($f)){
$p=getimagesize($archivo);
if($p[1]>$p[0]){
//Vertical
?>
<table>
<tr><td><img src="<?php echo $archivo; ?>"></td><td></td>
</tr>
<tr><td>ID: <?php echo $_REQUEST[cod]; ?></td>
</tr>
<tr><td>
<?php
session_start();
if(!empty($ant))
echo "<a href=\"$ant\" onclick=\"top.cen.location='$anterior'\"><img src=\"../img-galeria/backbtn.gif\" width=\"44\" height=\"35\" border=\"0\"></a>";$_SESSION['usuario'];
?>
</td>
<td>
<?php
session_start();
if(!empty($sig))
echo "<a href=\"$sig\" onclick=\"top.cen.location='$siguiente'\"><img src=\"../img-galeria/nextbtn.gif\" width=\"44\" height=\"35\" border=0></a>";$_SESSION['usuario'];
?>
</td>
</tr>
</table>
<?php
//Horizontal
}else{
?>
<table>
<tr><td><img src="<?php echo $archivo; ?>"></td>
</tr>
</table>
<table>
<tr><td>ID: <?php echo $_REQUEST[cod]; ?></td>
</tr>
<td>
<?php
if(!empty($ant))
echo "<a href=\"$ant\" onclick=\"top.cen.location='$anterior'\"><img src=\"../img-galeria/backbtn.gif\" width=\"44\" height=\"35\" border=\"0\"></a>";$_SESSION['usuario'];
?>
</td>
<td>
<?php
if(!empty($sig))
echo "<a href=\"$sig\" onclick=\"top.cen.location='$siguiente'\"><img src=\"../img-galeria/nextbtn.gif\" width=\"44\" height=\"35\" border=0></a>";$_SESSION['usuario'];
?>
</td>
</tr>
</table>
<?php
}
}
?>
</body>
</html>