}
else
{
require('inc/biblio.php');
include('inc/cbdd.php');
$r=mysql_query("select `id`,`pwd`,`key` from `user` where `name`='$user'") or die('Erreur sql : '.mysql_error());
if(mysql_num_rows($r)==0) href('?err=Identifiant incorrect');
list($id,$pwd,$key)=mysql_fetch_row($r);
if($pwd==substr(crypt($pw,$key),2))
{
$pwc=hash_($pwd,ipsalt($_SERVER['REMOTE_ADDR']));
setcookie('id',$id,time()+36000); //expire dans 10h
setcookie('pwc',$pwc,time()+36000);
mysql_query("update `user` set `ip`='$REMOTE_ADDR' where `id`='$id'");
if($id==1) //admin
enter('admin.php');
else
enter('page1.php');
}
else
{
href("?user=$user&err=Mot de passe incorrect");
}
}
?>