Php , besoin d'aide
cyril88
-
vordano Messages postés 1685 Date d'inscription Statut Membre Dernière intervention -
vordano Messages postés 1685 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
je désire afficher la valeur stockée dans mon $_SESSION après un changement de page :
<?php session_start(); ?>
<?php
if (isset ($_POST['choix']))
{
if($_POST['choix'] == "1")
{ $_SESSION ['choix'] = 'un poste interieur'; }
else if ($_POST['choix'] == "2")
{ $_SESSION ['choix'] = 'deux postes interieur';}
else if($_POST['choix'] == "3")
{ $_SESSION ['choix'] = 'trois postes interieur';}
else if($_POST['choix'] == "4")
{ $_SESSION ['choix'] = 'quatre postes interieur';}
else if($_POST['choix'] == "5")
{ $_SESSION ['choix'] = 'cinq postes interieur';}
else { $_SESSION ['choix'] == 'ERREUR';}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="fr">
<head>
<title>Configurateur Individuel : choix des platines</title>
<meta charset="utf-8">
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>
<h1>Configurateur de Poste Interieur</h1>
<form method="post" action="A1a.php">
<br><p style="text align:center;" >
Vous avez choisi une platine en saillie avec l'option Audio , veuillez maintenant choisir le nombre de postes interieur que vous désirez , veuillez aussi choisir leurs types .
Attention vous ne pouvez pas choisir plus de 5 postes interieurs tout types confondus</p><br>
<script type="text/javascript">
function liste(b)
{
document.getElementById('div1').style.display = (b!=1? 'none':'block');
document.getElementById('div2').style.display = (b!=2? 'none':'block');
document.getElementById('div3').style.display = (b!=3? 'none':'block');
document.getElementById('div4').style.display = (b!=4? 'none':'block');
document.getElementById('div5').style.display = (b!=5? 'none':'block');
}
</script>
<fieldset><br>
Choisissez le nombre de postes que vous desirez avoir : <br><br>
<li><input type="radio" name="choix" value="1" onclick="liste(1);" id="radio1"> <label for="radio1" />je veux un poste interieur</label></li>
<li><input type="radio" name="choix" value="2" onclick="liste(2);" id="radio2"> <label for="radio2" />je veux deux postes interieur</label></li>
<li><input type="radio" name="choix" value="3" onclick="liste(3);" id="radio3"> <label for="radio3">je veux trois postes interieur</label></li>
<li><input type="radio" name="choix" value="4" onclick="liste(4);" id="radio4"> <label for="radio4">je veux quatre postes interieur</label></li>
<li><input type="radio" name="choix" value="5" onclick="liste(5);" id="radio5"> <label for="radio5">je veux cinq postes interieur</label></li>
<div id="div1" style="display:none"><br>
ect ...
ce bout de code marche , a la page suivante j'ai codé ceci :
<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="fr">
<head>
<title>Configurateur Individuel : choix des platines</title>
<meta charset="utf-8">
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>
<p>
Vous avez choisi <?php echo $_SESSION['choix']; ?>
</p>
<input type="submit" value="Valider">
</body>
</html>
et la surpriiise , impossible d'afficher la valeur contenue dans ma session , je ne comprend vraiment pas d'ou le problème vient , wamp serveur me dit qu'il y as une erreur dans " Vous avez choisi <?php echo $_SESSION['choix']; ?> " , bref je suis bloqué ...
je désire afficher la valeur stockée dans mon $_SESSION après un changement de page :
<?php session_start(); ?>
<?php
if (isset ($_POST['choix']))
{
if($_POST['choix'] == "1")
{ $_SESSION ['choix'] = 'un poste interieur'; }
else if ($_POST['choix'] == "2")
{ $_SESSION ['choix'] = 'deux postes interieur';}
else if($_POST['choix'] == "3")
{ $_SESSION ['choix'] = 'trois postes interieur';}
else if($_POST['choix'] == "4")
{ $_SESSION ['choix'] = 'quatre postes interieur';}
else if($_POST['choix'] == "5")
{ $_SESSION ['choix'] = 'cinq postes interieur';}
else { $_SESSION ['choix'] == 'ERREUR';}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="fr">
<head>
<title>Configurateur Individuel : choix des platines</title>
<meta charset="utf-8">
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>
<h1>Configurateur de Poste Interieur</h1>
<form method="post" action="A1a.php">
<br><p style="text align:center;" >
Vous avez choisi une platine en saillie avec l'option Audio , veuillez maintenant choisir le nombre de postes interieur que vous désirez , veuillez aussi choisir leurs types .
Attention vous ne pouvez pas choisir plus de 5 postes interieurs tout types confondus</p><br>
<script type="text/javascript">
function liste(b)
{
document.getElementById('div1').style.display = (b!=1? 'none':'block');
document.getElementById('div2').style.display = (b!=2? 'none':'block');
document.getElementById('div3').style.display = (b!=3? 'none':'block');
document.getElementById('div4').style.display = (b!=4? 'none':'block');
document.getElementById('div5').style.display = (b!=5? 'none':'block');
}
</script>
<fieldset><br>
Choisissez le nombre de postes que vous desirez avoir : <br><br>
<li><input type="radio" name="choix" value="1" onclick="liste(1);" id="radio1"> <label for="radio1" />je veux un poste interieur</label></li>
<li><input type="radio" name="choix" value="2" onclick="liste(2);" id="radio2"> <label for="radio2" />je veux deux postes interieur</label></li>
<li><input type="radio" name="choix" value="3" onclick="liste(3);" id="radio3"> <label for="radio3">je veux trois postes interieur</label></li>
<li><input type="radio" name="choix" value="4" onclick="liste(4);" id="radio4"> <label for="radio4">je veux quatre postes interieur</label></li>
<li><input type="radio" name="choix" value="5" onclick="liste(5);" id="radio5"> <label for="radio5">je veux cinq postes interieur</label></li>
<div id="div1" style="display:none"><br>
ect ...
ce bout de code marche , a la page suivante j'ai codé ceci :
<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="fr">
<head>
<title>Configurateur Individuel : choix des platines</title>
<meta charset="utf-8">
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>
<p>
Vous avez choisi <?php echo $_SESSION['choix']; ?>
</p>
<input type="submit" value="Valider">
</body>
</html>
et la surpriiise , impossible d'afficher la valeur contenue dans ma session , je ne comprend vraiment pas d'ou le problème vient , wamp serveur me dit qu'il y as une erreur dans " Vous avez choisi <?php echo $_SESSION['choix']; ?> " , bref je suis bloqué ...
A voir également:
- Php , besoin d'aide
- Easy php - Télécharger - Divers Web & Internet
- Expert php pinterest - Télécharger - Langages
- Retour a la ligne php - Forum Webmastering
- Alert php - Forum PHP
- Retour a la ligne php ✓ - Forum PHP
2 réponses
salut,
Est ce que le problème ne viendrait pas de la, tu envoie ton formulaire sur une autre page, et tu traite $_POST sur la page de ton formulaire ?
<form method="post" action="A1a.php">
Est ce que le problème ne viendrait pas de la, tu envoie ton formulaire sur une autre page, et tu traite $_POST sur la page de ton formulaire ?
Le problème ne vient visiblement pas de la , wamp serveur me dit qu'il y as une erreur a cette ligne :
Vous avez choisi <?php echo $_SESSION['choix']; ?>
Vous avez choisi <?php echo $_SESSION['choix']; ?>
j'ai écris le code suivant :/ :
<?php session_start(); ?>
<?php
if (isset ($_POST['choix']))
{
if($_POST['choix'] == "1")
{ $_SESSION ['choix'] = 'un poste interieur'; }
else if ($_POST['choix'] == "2")
{ $_SESSION ['choix'] = 'deux postes interieur';}
else if($_POST['choix'] == "3")
{ $_SESSION ['choix'] = 'trois postes interieur';}
else if($_POST['choix'] == "4")
{ $_SESSION ['choix'] = 'quatre postes interieur';}
else if($_POST['choix'] == "5")
{ $_SESSION ['choix'] = 'cinq postes interieur';}
else { $_SESSION ['choix'] == 'ERREUR';}
}
?>
<?php session_start(); ?>
<?php
if (isset ($_POST['choix']))
{
if($_POST['choix'] == "1")
{ $_SESSION ['choix'] = 'un poste interieur'; }
else if ($_POST['choix'] == "2")
{ $_SESSION ['choix'] = 'deux postes interieur';}
else if($_POST['choix'] == "3")
{ $_SESSION ['choix'] = 'trois postes interieur';}
else if($_POST['choix'] == "4")
{ $_SESSION ['choix'] = 'quatre postes interieur';}
else if($_POST['choix'] == "5")
{ $_SESSION ['choix'] = 'cinq postes interieur';}
else { $_SESSION ['choix'] == 'ERREUR';}
}
?>
je serai tenté te dire de faire
et utiliser une redirection dans
mais le plus simple a mon avis serai de mettre ce bout de code dans l'autre page