Essaye ceci :
Dans recherche_client.php:
<?php
session_start();
require_once('connexion.php');
/*
-----------------------------------
------ SCRIPT DE PROTECTION -------
-----------------------------------
*/
// On relaye la session
if (session_is_registered("authentification") && $_SESSION['privilege'] == "com" || $_SESSION['privilege'] == "prod"){ // vérification sur la session authentification (la session est elle enregistrée ?)
// redirection possible
}else{
header("Location:index.php?erreur=intru"); // redirection en cas d'echec
}
?>
<html>
<head>
<title>Recherche code client</title>
</head>
<body background="image/back.jpg" border="0" bordercolor="#ffffdd">
<h2 align="center">Recherche code client</h2>
<form method="POST" action="recherche_client.php">
<table width="500" height="300" align="center">
<tr>
<td width="45%" align="left"><b>Libellé client/société :</b></td>
<td align="left"><input type="texte" name="libelle"></td>
</tr>
<tr>
<td align="left"><b>Département :</b></td>
<td align="left"><input type="texte" name="dept"></td>
</tr>
<tr>
<td align="center"><INPUT Type="Button" Value="Fermer cette fenêtre" onclick="javascript:window.close()"></td>
<td align="center"><INPUT Type="submit" name="rechercher" value="Rechercher le code"></td>
</tr>
</table>
</form method="POST">
<?php
if ($_POST["rechercher"]) {
$libelle=$_POST["libelle"];
$dept=$_POST["dept"];
if ($libelle=="" && $dept=="") {
$message="Veuillez renseigner au moins un champs !";
echo $message;
exit;
}
//-------------------------Connexion au SERVEUR SQL SRV-S5-LEBLANC POUR RECHERCHE DU CODE CLIENT---------------------------------
$connexion=mssql_connect("******","**","**") or die("<p>Echec de connexion!");
mssql_select_db("DB000000", $connexion) or die ("<p>Echec de connexion à la base de donnée!");
if ($connexion){
$SQL=mssql_query("SELECT T_TIERS,T_LIBELLE,T_CODEPOSTAL,T_VILLE FROM TIERS WHERE T_LIBELLE LIKE '%".$libelle."%' AND T_CODEPOSTAL LIKE '".$dept."%'", $connexion);
if ($SQL) {
$result=mssql_fetch_array($SQL);
if ($result!=null){
$result=mssql_fetch_array($SQL);
$tab_code=$result["T_TIERS"];
$_SESSION["code"] = $tab_code;
echo "code enregistré";
}
}else {
echo "Aucun résultat trouvé !";
}
}
}
?>
<div><?php echo $message; ?></div>
</body>
</html>
et dans le fichier fichesdes.php :<?php
session_start(); // On relaye la session
require_once('connexion.php');
/* -----------------------------------
* ------ SCRIPT DE PROTECTION -------
* ----------------------------------- */
if (session_is_registered("authentification") && $_SESSION['privilege'] == "com" || $_SESSION['privilege'] == "prod" || $_SESSION['privilege'] == "simu"){ // vérification sur la session authentification (la session est elle enregistrée ?)
//eventuelle redisrection ou code divers...
}else{ header("Location:index.php?erreur=intru"); // redirection en cas d'echec
}
?>
<!-- FORMULAIRE FICHE DESCRIPTIVE -->
<html>
<head>
<title>EasyFiche</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table style="width: 1024px; height: 768px; text-align: left; margin-left: auto; margin-right: auto;" background="image/back.jpg" border="0" bordercolor="#ffffdd">
<tbody>
<tr>
<td style="text-align: justify;">
<form name="form_fiche" method="post" action="traitement_fiche.php">
.....
<?php
if (isset($_SESSION["code"]) && !empty($_SESSION["code"])){
$codeClient = $_SESSION["code"];
}
else{
$codeClient="";
}
?>
<input name="client" size="15" maxlength="40" type="text" value="<?php echo $codeClient; ?>">
<input value="Rechercher code" type="button" onclick="window.open('recherche_client.php','Client')">
.....
@+