If $_GET['page'] = "acc" ???

Fermé
prizt - 4 janv. 2011 à 18:55
.Zoro. Messages postés 263 Date d'inscription mardi 17 août 2010 Statut Membre Dernière intervention 8 mai 2020 - 4 janv. 2011 à 22:32
Bonjour,


j'ai un problème avef ma balise php :

<?php
if $_GET['page'] = "acc" $destination="accueil.html";
if $_GET['page'] = "his" $destination="historique.html";
if $_GET['page'] = "gal" $destination="galerie.html";
if $_GET['page'] = "ins" $destination="inscription.html";
if $_GET['page'] = "con" $destination="contact.html";
if $_GET['page'] = "new" $destination="news.html";
if $_GET['page'] = "pre" $destination="presentation.html";

elseif $_GET['page'] = "acc" $destination="accueil.html";
?>

j'aimerais faire apparaitre la page d'accueil par défaut, mais chaque fois que je lance l'url du site, c'est plutot un message d'erreur qui s'affiche sur le fait que la fonction include n'a pas pu réaliser une action.
SVP aidez moi. MERCI
A voir également:

2 réponses

coeus Messages postés 3019 Date d'inscription samedi 13 janvier 2007 Statut Membre Dernière intervention 19 juin 2013 119
4 janv. 2011 à 21:46
Ou encore mieux :
switch($_GET['page']) {
	case "acc" : $destination = "accueil.html"; break;
	case "his" : $destination = "historique.html"; break;
	case "gal" : $destination = "galerie.html"; break;
	case "ins" : $destination = "inscription.html"; break;
	case "con" : $destination = "contact.html"; break;
	case "new" : $destination = "news.html"; break;
	case "pre" : $destination = "presentation.html"; break;
	default : $destination = "accueil.html"; break;
}


Et puis en commençant, on ne fait pas
if ($x = $y) {...}

on fait
if ($x == $y) {...}

Ça pouvait bien ne pas fonctionner ! :-P
1
.Zoro. Messages postés 263 Date d'inscription mardi 17 août 2010 Statut Membre Dernière intervention 8 mai 2020 33
4 janv. 2011 à 22:32
exact pour le ==
avec le copié-collé
je n'ai pas fait attention a sa
0
.Zoro. Messages postés 263 Date d'inscription mardi 17 août 2010 Statut Membre Dernière intervention 8 mai 2020 33
4 janv. 2011 à 19:02
if ($_GET['page'] = "acc") { $destination="accueil.html"; }
elseif ($_GET['page'] = "his") { $destination="historique.html"; }
elseif(...
...
else {$destination="accueil.html" }



voici la syntaxe

if ( condition ) { action }
elseif ( aute condition ) { autre action }
else { action par defaut }
0