CONNEXION
  • RetourJeux
    • Sorties
    • Hit Parade
    • Les + populaires
    • Les + attendus
    • Soluces
    • Tous les Jeux
    • Gaming
  • RetourActu Gaming
    • News
    • Astuces
    • Tests
    • Previews
    • Toute l'actu gaming
  • RetourBons plans
    • Bons plans
    • Bons plans Smartphone
    • Bons plans Hardware
    • Bons plans Image et Son
    • Bons plans Amazon
    • Bons plans Cdiscount
    • Bons plans Decathlon
    • Bons plans Fnac
    • Tous les Bons plans
  • RetourJVTech
    • Actus High-Tech
    • Intelligence Artificielle
    • Smartphones
    • Mobilité urbaine
    • Hardware
    • Image et son
    • Tutoriels
    • Tests produits High-Tech
    • Guides d'achat High-Tech
    • JVTech
  • RetourCulture
    • Actus Culture
    • Culture
  • RetourVidéos
    • A la une
    • Gaming Live
    • Vidéos Tests
    • Vidéos Previews
    • Gameplay
    • Trailers
    • Chroniques
    • Replay Web TV
    • Toutes les vidéos
  • RetourForums
    • Hardware PC
    • PS5
    • Switch 2
    • Xbox Series
    • Switch
    • Pokemon pocket
    • FC 25 Ultimate Team
    • League of Legends
    • Tous les Forums
  • PC
  • PS5
  • Xbox Series
  • Switch 2
  • PS4
  • One
  • Switch
  • iOS
  • Android
  • MMO
  • RPG
  • FPS
En ce moment Genshin Impact Valhalla Breath of the wild Animal Crossing GTA 5 Red dead 2
Liste des sujets

[help]Variable de session couleur

Wistaro
Wistaro
Niveau 6
31 décembre 2011 à 02:11:05

Voila,
je voudrait que sur mon site, l'utilisateur se connecte, puis via une page "profil.php" puisse changer la couleur de fond de la page et la variable de session $_couleur est par défaut égale a "verte" par exemple.
Dans le "head" de ma page web, il y aura:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>PSPFlash-le site</title>

<?php if(!empty($_SESSION['couleur']) AND $_SESSION['couleur']=='default')

{?>

<link rel="stylesheet" href="style-base.css" type="text/css" />

<?php

}

else

{?>

<link rel="stylesheet" href="style-deco.css" type="text/css" />

<?php

}?>

</head>
<body>
<table>
<tr>
<td colspan="6"><img src="banniere.jpg" alt="PSPFlash" /></td>
</tr>
<div id="menu">
<tr>
<td><a href="index.php">News</b></a></td>
<td><a href="jeux.php">Jeux</a></td>
<td><a href="anim.php">Animations</a></td>
<td><a href="utils.php">Utilitaires</a></td>
<td><a href="liens.php">Liens</a></td>
<td><a href="contact.php">Me contacter</a></td>
</tr>
<tr>
<td><a href="tchat.php">T'chat</a></td>
<td><a href="forum">Forum</a></td>
<td><a href="images.php"> Images</a></td>

<?php
if(!empty($_SESSION['pseudo']))
{?>
<td><a href="pro.php">Profil</a></td>
<td><a href="deco.php">Déconnexion</a></td>
<td><a href="users.php">Membres</a></td>

<?php
}
else
{?>
<td><a href="connexion.php">Connexion</a></td>
<td><a href="inscription.php">Inscription</a></td>
<td><a href="portails.php"> Portails</a></td>
<?php
}?>
</tr>
<tr>
<?php
if(!empty($_SESSION['pseudo']))
{?>
<td><a href="mp.php">Messages</a></td>
<td><a href="infos.php">Infos</a></td>
<td><a href="theme.php">Thèmes</a></td>

<?php
}
else
{?>

<?php
}?>

</tr>
</div>

Mais si rajoute ceci:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>PSPFlash-le site</title>

<?php if(!empty($_SESSION['couleur']) AND $_SESSION['couleur']=='default')

{?>

<link rel="stylesheet" href="style-base.css" type="text/css" />

<?php

}

else

{?>

<link rel="stylesheet" href="style-deco.css" type="text/css" />

<?php

}?>

<?php if(!empty($_SESSION['couleur']) AND $_SESSION['couleur']=='white')

{?>

<link rel="stylesheet" href="style.css" type="text/css" />

<?php

}

else

{?>

<link rel="stylesheet" href="style-white.css" type="text/css" />

<?php

}?>

</head>
<body>
<table>
<tr>
<td colspan="6"><img src="banniere.jpg" alt="PSPFlash" /></td>
</tr>
<div id="menu">
<tr>
<td><a href="index.php">News</b></a></td>
<td><a href="jeux.php">Jeux</a></td>
<td><a href="anim.php">Animations</a></td>
<td><a href="utils.php">Utilitaires</a></td>
<td><a href="liens.php">Liens</a></td>
<td><a href="contact.php">Me contacter</a></td>
</tr>
<tr>
<td><a href="tchat.php">T'chat</a></td>
<td><a href="forum">Forum</a></td>
<td><a href="images.php"> Images</a></td>

<?php
if(!empty($_SESSION['pseudo']))
{?>
<td><a href="pro.php">Profil</a></td>
<td><a href="deco.php">Déconnexion</a></td>
<td><a href="users.php">Membres</a></td>

<?php
}
else
{?>
<td><a href="connexion.php">Connexion</a></td>
<td><a href="inscription.php">Inscription</a></td>
<td><a href="portails.php"> Portails</a></td>
<?php
}?>
</tr>
<tr>
<?php
if(!empty($_SESSION['pseudo']))
{?>
<td><a href="mp.php">Messages</a></td>
<td><a href="infos.php">Infos</a></td>
<td><a href="theme.php">Thèmes</a></td>

<?php
}
else
{?>

<?php
}?>

</tr>
</div>
En gros, pour mettre une 2e couleure, la cela ne fontionne pas, losque le membre se connecte, il a toujours le disign syle-deco.css...
Merci de maider

Pseudo supprimé
Pseudo supprimé 31 décembre 2011 à 02:32:09

Utilise ça si tu veux obtenir de l'aide, sinon, c'est illisible :
http://wall.deblan.fr/

Pseudo supprimé
Pseudo supprimé 31 décembre 2011 à 02:33:06

Sinon, tu ne devrais pas utiliser des sessions pour modifier ce genre de chose, mais plutôt un cookie, renseigne-toi ici :
http://www.siteduzero.com/tutoriel-3-14563-variables-superglobales-sessions-et-cookies.html#ss_part_3

Wistaro
Wistaro
Niveau 6
31 décembre 2011 à 11:30:18

ok je vais voir

Wistaro
Wistaro
Niveau 6
31 décembre 2011 à 11:38:16

http://wall.deblan.fr/x2002/html/1/ ici

ParaPlayGeek
ParaPlayGeek
Niveau 7
31 décembre 2011 à 12:32:55

La première condition c'est pas plutôt :

if(!isset($_SESSION['couleur']) || $_SESSION['couleur'] == "default") {

Ce qui signifie, si la session couleur n'existe pas, ou qu'elle est égale à "default" alors .. :)

Pseudo supprimé
Pseudo supprimé 31 décembre 2011 à 14:13:03

Tu a bien mis session_start() dans ton fichier ?

Kalikawa
Kalikawa
Niveau 7
01 janvier 2012 à 16:14:02

Tu peux aussi mettre les infos de la couleur dans une base de données.

Wistaro
Wistaro
Niveau 6
01 janvier 2012 à 18:45:30

@Ja-ko : oui bien avec. la connection a la bdd
@kalikawa:. c fait

@TOUS
help!

Sous forums
  • Aide à l'achat Mac
  • Création de Jeux
  • Linux
  • Création de sites web
  • Programmation
  • Internet
  • Steam Deck
  • Macintosh
  • Hardware
La vidéo du moment