El código de la página de login. Lo importante está de la linea 54 a la 64.
Código PHP:
Ver original<?php require_once('Connections/incid_preventiva.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;
}
}
?>
<?php
// *** Validate request to login to this site.
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['caja_usuario'])) { $loginUsername=$_POST['caja_usuario'];
$password=$_POST['caja_contrasenia'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "gestion/ges_inci_nuevos.php";
$MM_redirectLoginFailed = "login.php";
$MM_redirecttoReferrer = false;
$LoginRS__query=sprintf("SELECT LOGIN, CONTRASENA, ID_USUARIO FROM usuarios WHERE LOGIN=%s AND CONTRASENA=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
if ($loginFoundUser) {
$loginStrGroup = "";
//declare two session variables and assign them
$_SESSION['MM_Idusuario'] = $row['ID_USUARIO'];
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess ); }
else {
header("Location: ". $MM_redirectLoginFailed ); }
}
?>
<!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>Documento sin tÃ*tulo</title>
<link href="estilos.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="100%" border="0" align="center">
<tr>
<td><table width="95%" border="0" align="center">
<tr>
<td><img src="imagenes/logo_cabecera.gif" alt="" width="425" height="58" /></td>
</tr>
<tr>
<td><table width="95%" border="0" align="center">
<tr align="center">
<td class="tabla_cabecera">Verificación de acceso a Gestión de Incidentes</td>
</tr>
</table>
<form ACTION="<?php echo $loginFormAction; ?>" id="form1" name="form1" method="POST">
<table width="50%" border="0" align="center" class="table_centrada_azul">
<tr align="center">
<td> </td>
</tr>
<tr align="center">
<td>Usuario</td>
</tr>
<tr align="center">
<td><label for="caja_usuario"></label>
<input type="text" name="caja_usuario" id="caja_usuario" /></td>
</tr>
<tr align="center">
<td>Contraseña</td>
</tr>
<tr align="center">
<td><label for="caja_contrasenia"></label>
<input type="password" name="caja_contrasenia" id="caja_contrasenia" /></td>
</tr>
<tr align="center">
<td> </td>
</tr>
<tr align="center">
<td><input type="submit" name="boton_enviar" id="boton_enviar" value="Enviar" /></td>
</tr>
<tr align="center">
<td> </td>
</tr>
</table>
</form>
<p> </p>
<p> </p></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
Y en esta está cómo trato de recoger el dato. Quitando que os dejo el comienzo para que se vea que aparece el session_start() lo interesante es lo último.
Código PHP:
Ver original<?php require_once('../Connections/incid_preventiva.php'); ?>
<?php
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); $isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}
?>
.
.
.
<body>
<input name="REVISOR" type="" id="REVISOR" value="<?php echo $_SESSION['MM_Username']; ?>" />
<input name="REVISOR" type="" id="REVISOR" value="<?php echo $_SESSION['MM_Idusuario']; ?>" />
</body>
Con esto lo que consigo es que en una caja veo el contenido de la variable MM_Username pero en la otra no consigo nada