Tengo una pagina login.php Creada gracias A Dreamweaver CS6
Y lo que quiero hacer es agregar mas $_SESSION ya que con el codigo generado por dreamw... posee las siguientes Variables
Código PHP:
$_SESSION['MM_Username'] = $loginUsername;//el name del user conectado
$_SESSION['MM_UserGroup'] = $loginStrGroup;//es el rango , que uso para restringir el acceso
Cita:
codigo de login.php:-iduser
-mail
-user
-password
-rango
-genero
-avatar
-user
-password
-rango
-genero
-avatar
Código PHP:
<?php require_once('../Connections/localhost.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['user'])) {
$loginUsername=$_POST['user'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "rango";
$MM_redirectLoginSuccess = "prueba.php";
$MM_redirectLoginFailed = "login.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_localhost, $localhost);
$LoginRS__query=sprintf("SELECT `user`, password, rango FROM `user` WHERE `user`=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $localhost) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = mysql_result($LoginRS,0,'rango');
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_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 );
}
}
?>
<form name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
<div align="center">
<table width="200" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><label for="user">Usuario<br>
</label>
<input type="text" name="user" id="user"></td>
</tr>
<tr>
<td><label for="password">Pass<br>
</label>
<input type="password" name="password" id="password"></td>
</tr>
<tr>
<td align="center"><input type="submit" name="button" id="button" value="Login"></td>
</tr>
</table>
</div>
</form>