<?php require_once('../Connections/ ligacao.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();
}
if ((!isset($_REQUEST['flag'])) and (isset($_REQUEST['ordem']))){
$loginUsername=$_REQUEST[' username'];
$password=$_REQUEST[' password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "login.php?login=ok&flag=sim";
$MM_redirectLoginFailed = "login.php?login=nok&flag=sim" ;
$MM_redirecttoReferrer = false;
mysql_select_db($database_ ligacao, $ligacao);
$LoginRS__query=sprintf(" SELECT username, password FROM utilizadores WHERE username=%s AND password=%s",
GetSQLValueString($ loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $ligacao) 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 );
}
}
else
if ((isset($_REQUEST['flag'])) and ($_REQUEST['login']=="ok")){
echo "&resultado=ok";
}else if ((isset($_REQUEST['flag'])) and ($_REQUEST['login']=="nok")){
echo "&resultado=nok";
}
?>
--- AS2
recebe = new LoadVars();
envia = new LoadVars();
bt.onRelease = function() {
ordem = "sim";
envia.username = username;
envia.password = password;
envia.ordem = ordem;
};
recebe.onLoad = function(exito) {
if (exito) {//devolve true se houver sucesso na ligacao
resultado = recebe.resultado;
switch (exito) {//só se for verdade, mas de qualquer modo n percebo como n sendo executa a primeira opção
case (resultado == "ok") :
msg1 = "1";
break;
case (resultado == "nok") :
msg1 = "0";
break;
default :
msg3 = "nop";
}
} else {
msg2 = "erro";
}
};
stop();
Sem comentários:
Enviar um comentário