Probleme de header:comment faire une authenti
ethan55
Messages postés
42
Statut
Membre
-
ShortCuT Messages postés 424 Statut Membre -
ShortCuT Messages postés 424 Statut Membre -
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 ...
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 ...
A voir également:
- Probleme de header:comment faire une authenti
- Bad pool header ✓ - Forum Windows
- Your browser sent a request that this server could not understand. size of a request header field exceeds server limit. ✓ - Forum Bureautique
- Rgb header c'est quoi - Forum Carte-mère/mémoire
- 400 bad request request header or cookie too large ✓ - Forum Google Chrome
- Bad request ... - Forum Réseaux sociaux
1 réponse
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
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