if($conn) {
$sql = "select name,login,password from users where login='".$login."' and password='".$password."'";
$stmt = sqlsrv_query($conn,$sql, array(), array( "Scrollable" => 'static' ));
$row = sqlsrv_num_rows($stmt);
if ($row>0) {
$myrow = sqlsrv_fetch_array($stmt,SQLSRV_FETCH_ASSOC);
if($remember=='on'){
setcookie("name", "", time()-60*60*24*365,'/');
setcookie("authorize", "", time()-60*60*24*365,'/');
setcookie("name", $login, time()+60*60*24*365,'/');
setcookie("authorize", $login.md5($password).$browser['name'].$browser['version'], time()+60*60*24*365,'/');
$_SESSION['login']="";
$_SESSION['name']="";
$_SESSION['login']=$myrow['login'];
$_SESSION['name']=base64_encode($myrow["name"]);
@header('Location: home.php');
} else {
$_SESSION['login']="";
$_SESSION['name']="";
$_SESSION['login']=$myrow['login'];
$_SESSION['name']=base64_encode($myrow["name"]);
@header('Location: home.php');
}
}
else {
@header('Location: index.php?error=1');
}
}
else {
@header('Location: index.php?error=2');