Hola, hice una página que recibe un dato en la variable s_username, pero hasta cierta parte del código tiene valor y luego queda vacía.
Código:
<?
session_start();
if(!isset($_SESSION['s_username']))header("location: ../usuarios/index.php");
?>
<html>
<head>
<title>Manuales</title>
<link href="estilos.css" rel="stylesheet" type="text/css" />
</head>
<font size="18"><p align = "center">Manuales</p></font>
<br><br>
<form method="post" action="index.php" enctype="multipart/form-data">
<b>Seleccione una marca:</b>
<?
echo $s_username; //Acá SI imprime el contenido de la variable.
?>
<select name="marca">
<?
echo $s_username; //Acá NO imprime el contenido de la variable.
set_time_limit(0);
$marca_elegida = $_POST["marca"];
$archivos = scandir($dir);
for ($i = 2; $i <= count($archivos)-1; $i++) {
if (is_dir($dir . "/" . $archivos[$i]) && $archivos[$i]!="." && $archivos[$i]!=".."){
echo "<option value=" . $archivos[$i];
if ($archivos[$i] == $marca_elegida) {echo " selected ";};
echo ">" . $archivos[$i] . "</option>";
}
}
?>
</select>
<input type="submit" value="Mostrar manuales">
</form>
<?
echo $s_username; //Acá NO imprime el contenido de la variable.
?>
<br><br>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td width='5%'></td>
<?
if ($s_username == 'Administrador'){?>
<td width='25%'><a href=agregar.php>Subir archivo(s)</a></td>
<td width='20%'><a href=agregamarca.php>Agregar marca</a></td>
<td width='20%'><a href=eliminamarca.php>Eliminar marca</a></td>
<?
}else{
?>
<td width='25%'></td>
<td width='20%'></td>
<td width='20%'></td>
<?
}
?>
<td width='40%'><a href=logout.php>Salir</a></td>
</tr>
</table>
<br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10%"></td>
<td width="90%"><b>ARCHIVO</b></td>
</tr>
</table>
<?
if ($marca_elegida <> "")
{
$directorio = $dir . "/" . $marca_elegida;
$archivos = scandir($directorio);
$fila = 0;
?>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<?
for ($i = 2; $i <= count($archivos)-1; $i++) {
if (!is_dir($directorio . "/" . $archivos[$i])){
if ($fila % 2 == 0)
{
echo("<tr bgcolor='#FAF3BB'>");
}else{
echo("<tr bgcolor='#E7DFA0'>");
}
if ($s_username == 'Administrador'){?>
<td width='10%'><a href='eliminar.php?id=<? echo $archivos[$i] ?>&marca=<? echo $marca_elegida ?>'>Eliminar</a></td>
<? }else{ ?>
<td width='10%'></td>
<?
}
?>
<td width='90%'><a href='descarga.php?id=<? echo $archivos[$i] ?>'><? echo $archivos[$i] ?></a></td>
</tr>
<?
$fila = $fila + 1;
}
}
}
?>
</table>
</body>
</html>
Para probar coloqué un echo y encontré hasta dónde tiene el valor.
¿Qué estoy haciendo mal?
Gracias desde yá por las respuestas.
Saludos