Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
E aí pessoal.. beleza?
To com um probleminha aki..
Eu tenho um sistema de login php aki e o seguinte:
-->caso exita o usuário, ele vai pra página x.php
-->senão, na mesma página do login, aparece um div dizendo q não existe o usuário.
o problema eh q eu não to conseguindo a div aparece e desaparece depois de um teste em php:
segue o código;
>
<?php require_once('../Connections/Conexao.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['login'])) {
$loginUsername=$_POST['login'];
$password=$_POST['senha'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "/escolacleia/etc/principal.php";
$MM_redirectLoginFailed = "/escolacleia/etc/index.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_Conexao, $Conexao);
$LoginRS__query=sprintf("SELECT login, senha FROM `admin` WHERE login=%s AND senha=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $Conexao) 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 );
**echo "<script type=\"text/Javascript\">camada(erro, false)</script>"; **chamada da função no teste php
}
else {
header("Location: ". $MM_redirectLoginFailed );
**echo "<script type=\"text/Javascript\">camada(erro, true)</script>"; **chamada da função no teste php
}
}
?>
<!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%22)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="/escolacleia/scripts/CSS/restrito.css" rel="stylesheet" type="text/css" />
<script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="titulo"><strong>Área Restrita - LOGIN</strong></div><br />
**<div id="erro">Login/Senha Inválidos. Por favor, informe corretamente as informações.</div>**div q aparece se dá erro
<form id="frmlogin" name="frmlogin" method="POST" action="<?php echo $loginFormAction; ?>" enctype="application/x-www-form-urlencoded">
<span id="edtLogin">
<label>Login:
<input type="text" name="login" id="login" />
</label>
<span class="textfieldRequiredMsg">O campo não pode ser vazio.</span><span class="textfieldInvalidFormatMsg">Formato Inválido.</span></span><br /><br />
<span id="edtSenha">
<label>Senha:
<input type="password" name="senha" id="senha" />
</label>
<span class="textfieldRequiredMsg">O campo não pode ser vazio.</span><span class="textfieldInvalidFormatMsg">Formato Inválido.</span></span><br /><br />
<input name="enviar" type="submit" value="Login" />
<input type="reset" name="Reset" id="button" value="Limpar" />
</form>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("edtLogin", "custom", {validateOn:["blur"]});
var sprytextfield3 = new Spry.Widget.ValidationTextField("edtSenha", "custom", {validateOn:["blur"]});
//-->
**function camada( sId, visivel ) { //função que esconde/mostra a camada**
var sDiv = document.getElementById( sId );
if( visivel == "true" ) {
sDiv.style.visibility = "visible";
} else {
sDiv.style.visibility = "hidden";
}
}
</script>
</body>
</html>
o código de esconder/mostrar a div não funciona...
Qualquer ajuda eh vinda...
Carregando comentários...