Pb Header dans PHP
Posté : 26 déc. 2008, 12:10
J'ai 2 fichiers php : Connexion.php et verif2.php(il va intéroger la base pour verifier si le login et le mdp existe.)
Connexion.php :
et verif2.php :
Warning: Cannot modify header information - headers already sent by (output started at /var/www/romain/projet/public_html/TPSynthese/lib/db_stage.class.php:141) in /var/www/romain/projet/public_html/TPSynthese/verif2.php on line 9
db_stage.class.php:141 étant la toute dernière ligne(où il n'y a riendans) db_stage.class.php
Merci d'avance pour les réponses
Romain
Connexion.php :
<?php // Et oui... Les short tag, c'est le mal.
/*===================================================*/
// Connexion.php
/*===================================================*/
include_once("lib/frame.class.php");
FRAME::en_tete();
FRAME::menu();
FRAME::corps_begin("Login");
login();
FRAME::corps_end();
FRAME::pied();
function login() // Cas 0
{
?>
</form>
<body>
<center>
<br />
<form action="verif2.php" method="POST">
<br />
Nom:
<input type="text" name="nom" value="" />
<br />
<br />
Pass:
<input type="password" name="pass" value="" />
<br />
<input type="submit" name="ok" value="ok" />
<br />
<br />
<?php
//on récupère le message d'erreur
$mesg = $_GET["message"];
?>
<br />
<b>
<font color = "red">
<?php $mesg ?>
</font>
</b>
</center>
</body>
<?php
}
?>
et verif2.php :
<?php session_start();
if( isset( $_POST['nom']) && isset($_POST['pass'])){
$nom = $_POST['nom'];
$pass = $_POST['pass'];
include_once("lib/db_stage.class.php");
if (verification($nom,$pass)==true){
$_SESSION['nom']=$nom;
header("Location: stageOK.php");
}
if (verification($nom,$pass)==false){
header("Location: stage.php");}
}
else{
header("Location: stage.php");
}
?>
<?
function verification($nom,$pass){
include_once("lib/db_stage.class.php");
$req = "select count(*) as n from pac_utilisateur where nom='$nom' ";
$t = DB_STAGE::select2($req);
$n = $t[0]->n;
if($n == 0) {return false;}// inexistant
$req = "select pass from pac_utilisateur where nom='$nom' ";
$t = DB_STAGE::select2($req);
$pass_ = $t[0]->pass;
if($pass==$pass_){
return true; // pass bon
} else {
return false; // pass errone
}
}
?>
et db_stage.class :<?
class DB_STAGE{
/************************************************************************/
// Connexion à la base
/************************************************************************/
function connect(){
$connexion=pg_connect("user=romain password=sql host=localhost dbname=romain") or die ("erreur de la requete");
return $connexion;
}
/***************************************************************/
// SELECT generique sur une table quelconque
/***************************************************************/
function select2($req){
$tab=array();
$connexion=DB_STAGE::connect();
$row = 0;
$reponse = pg_query($connexion, $req) or die("requete impossible !\n");
while ($tuple = pg_fetch_object($reponse)){
$tab[$row]=$tuple;
$row++;
}
return $tab;
DB_STAGE::close($connexion);
}
/***************************************************************/
// MAJ generique sur une table quelconque
/***************************************************************/
function maj($req){
$connexion=DB_STAGE::connect();
pg_query($connexion, $req) or die("requete impossible !\n");
DB_STAGE::close($connexion);
}
/***************************************************************/
// Fermeture de la connexion
/***************************************************************/
function close($connexion){
pg_close($connexion);
}
function select($requete){
$connexion = DB_STAGE::connect();
$reponse = pg_query($connexion, $requete) or die("requete impossible !");
return $reponse;
DB_STAGE::close($connexion);
}
}
?>
et j'ai comme erreurWarning: Cannot modify header information - headers already sent by (output started at /var/www/romain/projet/public_html/TPSynthese/lib/db_stage.class.php:141) in /var/www/romain/projet/public_html/TPSynthese/verif2.php on line 9
db_stage.class.php:141 étant la toute dernière ligne(où il n'y a riendans) db_stage.class.php
Merci d'avance pour les réponses
Romain