problème de session php

oriviera

Nouveau membre
Bonjour,
Voilà gros problme avec les sessions je sais ce n'est pas nouveau, mais je ne comprend rien car dans un cas de figure
ca fonctionne très bien et dans l'autre rien.

SVP un coup de main ca fait deux jours que j'essaie de me dé......patouiller et là je ne vois pas la solution.
Merci d'avance.


Trois scripts ou les sessions fonctionnent bien login.php verif.php et recupsession.php
FICHIER login.php
un formulaire

<html>
<head>
<title>PAGE UNE</title></head>
<body>
<form name="form" action="verif.php" method='post' enctype="multipart/form-data">
<table align="center" border="0">
<tr>
<td>Login :</td>
<td><input type="text" name="LOGIN" maxlength="250"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password"name="PASS" maxlength="10"></td>
</tr>
<tr>
<td>Num&eacute;ro de secu</td>
<td><input type="text" name="NUM_SS"></td>
</tr>
<tr>
<td>ID</td>
<td><input type="text" name="ID_ADMIN"></td>
</tr>
<tr>
<td>Nom</td>
<td><input type="text" name="NOM"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="log in"></td>
</tr>
</table>
</form>
</body>
</html>

FICHIER verif.php
recupération du formulaire de login.php

<?php require_once('../../../Connections/iupaic.php'); ?>
<?php
extract($_POST);
// je recupère toutes les données saisies dans login.php
$_SESSION['LOGIN'] = $LOGIN;
$_SESSION['PASS'] = $PASS;
$_SESSION['NUM_SS'] = $NUM_SS;
$_SESSION['ID_ADMIN'] = $ID_ADMIN;
$_SESSION['NOM'] = $NOM;
?>
<html>
<head>
<title>Document sans titre</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form2" enctype="multipart/form-data" method="post" action="recupsession.php" >
<input type="file" name="zoro">
<input type="submit" name="Submit" value="Envoyer">
</form>
</body>
</html>

fichier recupsession.php

<?php
extract($_POST);
// je recupère le chemin de mon fichier saisi dans verif.php
echo $zoro;
$_SESSION['essai'] = $zoro;
?>
<html>
<head>
<title>recup session</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<!-- ici j'ai bien tout-->
<?php
echo $LOGIN;
echo $PASS;
echo $NUM_SS;
echo $ID_ADMIN;
echo $NOM;

echo $zoro;
session_destroy();
?>
</body>
</html>

Dans ces trois scripts tout onctionne bien je récupère bien les infos que je fais circuler à l'aide de session
par contre ppour la suite ce n'est pas pareil.



Tous ces scripts ont été dévelppés avec DEAMWEAVER MX
FICHIER ajout.php


<?php require_once('../../../Connections/iupaic.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}

$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}

if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO equipe_administrative (ID_ADMIN, NOM, NUM_SS) VALUES (%s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['ID_ADMIN'], "int"),
GetSQLValueString($HTTP_POST_VARS['LOGIN'], "text"),
GetSQLValueString($HTTP_POST_VARS['NUM_SS'], "text"));

mysql_select_db($database_iupaic, $iupaic);
$Result1 = mysql_query($insertSQL, $iupaic) or die(mysql_error());

$insertGoTo = "ajoutimag.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_iupaic, $iupaic);
$query_admin = "SELECT ID_ADMIN FROM equipe_administrative ORDER BY ID_ADMIN DESC";
$admin = mysql_query($query_admin, $iupaic) or die(mysql_error());
$row_admin = mysql_fetch_assoc($admin);
$totalRows_admin = mysql_num_rows($admin);
// je fais une lecture pour récupérer le dernier enregistrement
$i = $row_admin['ID_ADMIN'];
$i++;
echo $i;
?>
<html>
<head>
<title>CREATION D'UNE PERSONNE</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v3.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='Le champ '+nm+' doit contenir une adresse e-mail.\n';
} else if (test!='R') { num = parseFloat(val);
if (val!=''+num) errors+='Le champ '+nm+' doit contenir un nombre.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' doit contenir un nombre entre '+min+' et '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += 'Le champ '+nm+' doit être rempli.\n'; }
} if (errors) alert(' Les erreurs suivantes se sont produites :\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
<body class="fondecran">
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">ID_ADMIN:</td>
<td><input type="text" name="admin" value="<?php echo $i;?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">NOM:</td>
<td><input type="text" name="NOM" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">NUM_SS:</td>
<td><input type="text" name="secu" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">&nbsp;</td>
<td><input type="submit" value="Insérer l'enregistrement"></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
<p>&nbsp;</p>

</body>
</html>
<?php
mysql_free_result($admin);
?>


Fichier ajoutimag.php


<?php require_once('../../../Connections/iupaic.php'); ?>
<?php

// //dans ce sript j'ai essayé de placer ici
echo "coucou de depart";
extract($_POST);
echo $secu;
echo $admin;
echo $NOM;
$_SESSION['secu']=$secu;
$_SESSION['admin']=$admin;
$_SESSION['NOM']=$NOM;
echo "coucou fin";
// //

$colname_ajoutimag = "1";
if (isset($HTTP_POST_VARS['id'])) {
$colname_ajoutimag = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['id'] : addslashes($HTTP_POST_VARS['id']);
}

// //dans ce sript j'ai essayé de placer là
echo "coucou de depart";
extract($_POST);
echo $secu;
echo $admin;
echo $NOM;
$_SESSION['secu']=$secu;
$_SESSION['admin']=$admin;
$_SESSION['NOM']=$NOM;
echo "coucou fin";
// //

mysql_select_db($database_iupaic, $iupaic);
$query_ajoutimag = sprintf("SELECT ID_ADMIN, NOM, DOSSIER_PHOTO, NUM_SS FROM equipe_administrative WHERE ID_ADMIN = %s", $colname_ajoutimag);
$ajoutimag = mysql_query($query_ajoutimag, $iupaic) or die(mysql_error());
$row_ajoutimag = mysql_fetch_assoc($ajoutimag);
$totalRows_ajoutimag = mysql_num_rows($ajoutimag);

// //dans ce sript j'ai essayé de placer là
echo "coucou de depart";
extract($_POST);
echo $secu;
echo $admin;
echo $NOM;
$_SESSION['secu']=$secu;
$_SESSION['admin']=$admin;
$_SESSION['NOM']=$NOM;
echo "coucou fin";
// //

?>
<html>
<head>
<title>Dossier photo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#CC0000">
<table width="75%" border="0 " align="center" dwcopytype="CopyTableCell">
<tr>
<td align="center">
<form name="form" method="post" action="../Uploadfichier/page_receptrice2.php" enctype="multipart/form-data">
<?php extract($_POST);

// //dans ce sript j'ai essayé de placer là
echo $secu;
echo $admin;
echo $NOM;
$_SESSION['secu']=$secu;
$_SESSION['admin']=$admin;
$_SESSION['NOM']=$NOM;
// //

mais rien ne fonctionne, je ne récupére rien

?>
<font color="#CC6600" size="4">Veuillez s&eacute;lectionner l'image &agrave;
charger :</font><font color="#CC9900">
<input type="file" name="aFile" />
<input type="submit" name="submitFile" value="Envoyer le fichier" />
</font>
</form>
</td>
</tr>
<tr>
<td align="center"><a href="../Formulaire/formulairegene.php">Retour au Menu
Formulaire</a><a href="administratif.php">Menu Administratif</a>
<a href="../../../index.php">Retour &agrave; l'Accueil</a></td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($ajoutimag);
?>


 

KangOl

Grand Maître
1/ balise
Code:
2/ élague ton code, je suis persuadé que tout n'est pas utile...
 

Lordsephiroth

Nouveau membre
Dans un fichier .php, à chaque fois que tu veux utiliser les variables de session tu dois mettre en première instruction la fonction session_start();

Cette fonction crée une session ou réactive la session si elle était suspendue pour une utilisateur.

Je précise bien que cette instruction doit être la PREMIERE sur ton fichier et dois figurer à chaque fois que tu veux accéder à la table $_SESSION[];

Lorsque tu veux détruire la session (genre sur le fichier logout.php), exécute la fonction session_destroy();
 

jasonconvenant

Nouveau membre
oublie dreamweaver !
Je me servai de dreamweaver MX avant et b1 c fini car depuis que j'ai appri le php c'est beaucoup plus court et je peu modifier tout ce que je veux et mettre des options !
 

EchoCedric

Grand Maître

Tu peux aussi faire tout ça dans DreamWeaver et bien plus. :sarcastic:
 
Vous devez vous inscrire ou vous connecter pour répondre ici.
Derniers messages publiés
Statistiques globales
Discussions
730 134
Messages
6 718 055
Membres
1 586 393
Dernier membre
mathhh28
Partager cette page
Haut