Page 1 sur 1

extraire variable d'une session

Posté : 16 nov. 2005, 11:53
par krakra4
Re,

j'ai modifié une page

je voudrais extraire la variable qui se trouve ds une session.
Il y a plusieurs choix si la variable est JSI redirection vers lecture JSI.
si autre redirection vers autre.
mon script merde 'just a little' :shock: :?

<?php
// choix du type ------------------
$choix=$_SESSION['type']; 
if $choix=="JSI" header ("location:http://xxxxxx/lectureJSI.php");
if $choix=="TQI" header ("location:http://xxxxxx/lectureTQI.php");
if $choix=="FTH" header ("location:http://xxxxxx/lectureFTH.php");
if $choix=="SER" header ("location:http://xxxxxx/lectureSER.php");
?>

merci pour votre aide

Posté : 16 nov. 2005, 12:57
par Truc
Salut, apparemment il ne manquerait que les parentheses:
<?php
// choix du type ------------------
$choix=$_SESSION['type'];
if ($choix=="JSI") header ("location:http://xxxxxx/lectureJSI.php");
if ($choix=="TQI") header ("location:http://xxxxxx/lectureTQI.php");
if ($choix=="FTH") header ("location:http://xxxxxx/lectureFTH.php");
if ($choix=="SER") header ("location:http://xxxxxx/lectureSER.php");
?>
si le chemin est le meme pour toutes les redirections:
<?php
// choix du type ------------------
$choix=$_SESSION['type'];
header ("location:http://xxxxxx/lecture".$choix.".php");
?>

re,

Posté : 16 nov. 2005, 13:10
par krakra4
merci bcp

j'ai fais une erreur en utilisant header car j'ai deja envoyé une instruction ds l'explorer.

comment faire en gardant ton script mais en utilisant une autre fonction que header.
*
merci

Posté : 16 nov. 2005, 13:48
par Cyrano
fais une redirection en Javascript dans ce cas:
<script type="text/javascript">
window.location = "url/autre/page.html";
</script>

re,

Posté : 16 nov. 2005, 14:16
par krakra4
désolé mais cela ne fonctionne pas - ou bien c encore moi qui est merdé :?
<?php
// choix du type ------------------ 
$choix=$_SESSION['type']; 
echo $choix;
?> 
<script type="text/javascript"> 
if ($choix=="JSI") window.location = "http://www.xxxx/lectureJSI.php";
if ($choix=="TRI") window.location = "http://www.xxxx/lectureTRI.php"; 
</script> 
il m'affiche ma variable $choix mais pas la redirection.

merci

Re: re,

Posté : 16 nov. 2005, 14:23
par zeus
Il faut garder la structure précédente mais en affichant le script JS a utiliser si besoin est
<?php
// choix du type ------------------
$choix=$_SESSION['type'];
$redirect_uri = "http://xxxxxx/lecture".$choix.".php";
echo "<script language='text/javascript'>".$redirect_uri."</script>";
?>

Posté : 16 nov. 2005, 14:30
par krakra4
MERCI


[RESOLU]