Probleme de header
ethan55
Messages postés
42
Statut
Membre
-
Timon1102 Messages postés 354 Statut Membre -
Timon1102 Messages postés 354 Statut Membre -
Bonjour je fais un projet pour une entreprise et voila le pb que j ai:
En fait ,je veux faire une authentification HTTP pour la base de donnees de l entreprise.Je travaille en php ,j ai ecrit le code suivant:
<html>
<body>
<?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');}
?>
</body>
</html>
et voila l erreur que j obtiens:
Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-82\www\auth.php:4) in c:\program files\easyphp1-82\www\auth.php on line 26
Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-82\www\auth.php:4) in c:\program files\easyphp1-82\www\auth.php on line 27
Je ne sais pas quoi faire .Si vous avez une idee...ca serait sympa
Merci d avance
En fait ,je veux faire une authentification HTTP pour la base de donnees de l entreprise.Je travaille en php ,j ai ecrit le code suivant:
<html>
<body>
<?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');}
?>
</body>
</html>
et voila l erreur que j obtiens:
Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-82\www\auth.php:4) in c:\program files\easyphp1-82\www\auth.php on line 26
Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-82\www\auth.php:4) in c:\program files\easyphp1-82\www\auth.php on line 27
Je ne sais pas quoi faire .Si vous avez une idee...ca serait sympa
Merci d avance
A voir également:
- Probleme de header
- 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
- Bad request ... - Forum Réseaux sociaux
- 400 bad request request header or cookie too large ✓ - Forum Google Chrome
8 réponses
c simple : tu envoies des headers alors que tu a deja envoyé du contenu.
tout ce que est header() doit etre place avant meme <html>
tout ce que est header() doit etre place avant meme <html>
... copier un autre script ;p
non a premiere vu je dirai qu'il suffirait de mettre tes 2 premieres lignes (<html><body>) apres ton passage php
non a premiere vu je dirai qu'il suffirait de mettre tes 2 premieres lignes (<html><body>) apres ton passage php
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question