Probleme de header:comment faire une authenti

Fermé
ethan55 Messages postés 42 Date d'inscription mercredi 8 juin 2005 Statut Membre Dernière intervention 21 novembre 2005 - 5 juil. 2005 à 11:07
ShortCuT Messages postés 419 Date d'inscription jeudi 16 octobre 2003 Statut Membre Dernière intervention 24 avril 2006 - 11 juil. 2005 à 09:59
je travaille sur EasyPhp et j essaie de faire une authentification HTTP pour ma page da acceuil.
Je vous montre mon code:

<?php

$auth=FALSE;

if ((isset($_SERVER['PHP_AUTH_USER']) AND
isset($_SERVER['PHP_AUTH_PW'])))
{
define('DB_USER','root');
define('DB_PASSWORD','');
define('DB_HOST','localhost');
define('DB_NAME','s_c_l_s');
$bd=@mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die ('Connexion à MySQL impossible:'.mysql_error());
mysql_select_db(DB_NAME)
OR die ('Sélection de la base de donnees impossible:'.mysql_error());

$rq="SELECT nom from ingenieur where nom='{$_SERVER['PHP_AUTH_USER']}'
AND password=PASSWORD('{$_SERVER['PHP_AUTH_PW'] }')";
$result=mysql_query($rq);
$ligne=@mysql_fetch_array($result);
if($ligne)
{$auth=TRUE;}}
if(!$auth){
header('WWW-Authenticate:Basic realm="Sunbelt Call Logging System"');
header('HTTP/1.0 401 Unauthorized');}

?>
<html>
<body>
</html>
</body>


et voila ce que j obtiens :

Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-82\www\auth.php:3) in c:\program files\easyphp1-82\www\auth.php on line 25

Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-82\www\auth.php:3) in c:\program files\easyphp1-82\www\auth.php on line 26

Si vous pouvez peut etre m aider ca serait tres sympa ...

1 réponse

ShortCuT Messages postés 419 Date d'inscription jeudi 16 octobre 2003 Statut Membre Dernière intervention 24 avril 2006 87
11 juil. 2005 à 09:59
Bonjour ,
je ne peut pas spécialemnet te regler ton problème mais :
- les chmod ( permission ) sont souvent la cause des probleme de ce type
chmod est sous linux l'equivalent des permissions ntfs sous windows , il faut les indiqué dans le fichier config d'apache ...

sinon pour un accès securisé simple et garantie , utilise un .htacces

a bientot
------------------------------
Gwen
0