Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Criei um Sistema de Login usando phpmyadmin (mySql) com o banco de dados tudo certinho,
configurei no dreamweaver através do painel Login In User, o sistema de login, e ficou assim:
<?php require_once('Connections/ConnIntranet.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$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_nome'])) {
$loginUsername=$_POST['usu_nome'];
$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_ConnIntranet, $ConnIntranet);
$LoginRS__query=sprintf("SELECT usu_nome, usu_senha FROM usuarios WHERE usu_nome=%s AND usu_senha=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $ConnIntranet) 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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Intranet - M. Vitali</title>
<link href="login-box.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="login-box">
<H2>Login</H2>
<?php
$dias_semana = array('Domingo', 'Segunda-Feira', 'Terça-Feira', 'Quarta-Feira', 'Quinta-Feira', 'Sexta-Feira', 'Sábado');
$mes_ano = array('Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro');
echo $dias_semana[date("w")] . " " . date("j \d\e ") . $mes_ano[date("n")] . date(" \d\e Y - ") . date("H:i");
?><br />
<br />
<?php if(isset($_GET["login_errado"])) { ?>
<p><strong>O login e/ou a senha está errado!</strong></p>
<?php } ?>
<form name="form1" id="form1" method="POST" action="<?php echo $loginFormAction; ?>">
<div id="login-box-name" style="margin-top:20px;">Usuario:</div><div id="login-box-field" style="margin-top:20px;"><input name="usu_nome" class="form-login" title="Usuário" value="" size="30" maxlength="2048" id="usu_nome" /></div>
<div id="login-box-name">Senha:</div><div id="login-box-field"><input name="usu_senha" type="password" class="form-login" title="Senha" value="" size="30" maxlength="2048" id="usu_senha" /></div>
</form>
<br />
<span class="login-box-options"><input type="checkbox" name="1" value="1"> Lembrar Usuário <a href="#" style="margin-left:30px;">Esqueceu email/senha?</a>
</span>
<br />
<br />
<a href="#"> <img src="images/login-btn.png" width="103" height="42" style="margin-left:90px;" /></a>
</div>
</body>
</html>
Porém quando aperto o botão de Login, ele não faz checagem nenhuma no banco de dados e se coloco um usuario e senha que não estão cadastrados no banco de dados
era para aparecer a seguinte mensagem:
"O login e/ou a senha está errado!"
mas nem isso aparece, porque? :(
Carregando comentários...