Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Olá pessoal estou com uma grande duvida em relação ao meu sistema de login, pois ele funciona muito bem, mas gostaria de fazer uma área restrita para cada cliente onde cada um teria sua propria página onde só ele terá acesso.
Segue abaixo o meu código , me ajudem por favor .
<?php require_once('Connections/f.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['usuario'])) {
$loginUsername=$_POST['usuario'];
$password=$_POST['senha'];
$MM_fldUserAuthorization = "nivel";
$MM_redirectLoginSuccess = "index.php";
$MM_redirectLoginFailed = "logar.php?login_erro";
$MM_redirecttoReferrer = false;
mysql_select_db($database_f, $f);
$LoginRS__query=sprintf("SELECT usuario, senha, nivel FROM usuario WHERE usuario=%s AND senha=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $f) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = mysql_result($LoginRS,0,'nivel');
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 );
}
}
?><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
<body>
<table width="48" height="47" border="0">
<tr>
<td><a href="index.php?home"><img src="button/voltarnbm.png" width="104" height="60" /></a></td>
</tr>
</table>
<p> </p>
<table width="93" height="53" border="0" align="center">
<tr>
<td><h1> Login</h1></td>
</tr>
</table>
<p> </p>
<form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
<table align="center">
<tr>
<td>Usuário</td>
<td><label for="usuario"></label>
<input type="text" name="usuario" id="usuario" /></td>
</tr>
<tr>
<td>Senha</td>
<td><label for="senha"></label>
<input type="password" name="senha" id="senha" /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="button" id="button" value="Entrar" /></td>
</tr>
</table>
</form>
<br>
<?php
if (isset($_GET['login_erro'])) {
?>
<table align="center">
<tr>
<td><p>Login ou senha nao confere</p></td>
</tr>
</table>
<?php }
?>
<table width="232" border="0" align="center">
<tr>
<td>Ainda não é registrado? <a href="cadastro_usu.php">Clique aqui </a></td>
</tr>
</table>
<p> </p>
</body>
</html>Carregando comentários...