Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Ola, eu novamente, estou precisando de outra coisa, eu acho que sei mais ou menos como fazer funcionar, mas, não tenho certeza
é o seguinte, eu fiz um sistema de login simples, tem tbm um sistema de cadastro de usuarios com senha criptografada, até ai tah tudo bem, o que eu preciso é (eu acho) que ele tenha permissões, mas, que seja uma permissão diferente para cada usuario, por exemplo, quando for o usuario fulano que quer se logar, abre uma pagina personalizada para ele, ai, se ele sair e o beltrano quiser entrar, abre outra pagina personalizada para ele...
A tabela do banco de dados é uma normal, com ID, nome, email, senha e data...
os codigos da pagina login.php
<?php require_once('../Connections/bd.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['usu_email'])) {
$loginUsername=$_POST['usu_email'];
$password=md5($_POST['usu_senha)'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "index.php";
$MM_redirectLoginFailed = "login.php?login_errado=true";
$MM_redirecttoReferrer = false;
mysql_select_db($database_bd, $bd);
$LoginRS__query=sprintf("SELECT usu_email, usu_senha FROM clientes WHERE usu_email=%s AND usu_senha=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $bd) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
//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 );
}
}
?>
<!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">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login ftp</title>
</head>
<body><br />
<?php if(isset($_GET["login_errado"])) { ?>
<p><strong>O login e/ou senha não consta em nosso banco de dados.</strong></p>
<?php } ?>
<form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
E-mail:
<input type="text" name="usu_email" id="usu_email" />
<br />
<br />
Senha:
<input type="password" name="usu_senha" id="usu_senha" />
<br />
<br />
<input type="submit" name="button" id="button" value="Entrar" />
</form>
</body>
</html>
os da pagina cadastro.php
<?php require_once('../Connections/bd.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;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO clientes (usu_nome, usu_email, usu_senha, usu_data) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['usu_nome'], "text"),
GetSQLValueString($_POST['usu_email'], "text"),
GetSQLValueString($_POST['usu_senha'], "text"),
GetSQLValueString($_POST['usu_data'], "date"));
mysql_select_db($database_bd, $bd);
$Result1 = mysql_query($insertSQL, $bd) or die(mysql_error());
$insertGoTo = "cadastro.php?cadastro_sucesso=true";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<!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">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cadastro</title>
</head>
<body><?php if(isset($_GET["cadastro_sucesso"])) { ?>
<p><strong>Cadastro de cliente efetuado com sucesso, obrigado.</strong></p>
<?php } ?><br />
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Nome:</td>
<td><input type="text" name="usu_nome" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">E-mail:</td>
<td><input type="text" name="usu_email" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Senha:</td>
<td><input type="password" name="usu_senha" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Data:</td>
<td><input name="usu_data" type="text" value="<?php echo date('Y/m/d'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Cadastrar cliente" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p>
</body>
</html>
alguem sabe?Carregando comentários...