Php help me

Résolu/Fermé
liliana23info Messages postés 8 Date d'inscription jeudi 4 juin 2009 Statut Membre Dernière intervention 4 juin 2009 - 4 juin 2009 à 18:41
liliana23ino Messages postés 1 Date d'inscription vendredi 5 juin 2009 Statut Membre Dernière intervention 5 juin 2009 - 5 juin 2009 à 11:46
Bonjour,
jveit garder les selection des bouttons radio de mon formulaire apres avoir un message d'erreur aider moi
A voir également:

8 réponses

Dr Zoidberg Messages postés 529 Date d'inscription jeudi 28 juin 2007 Statut Membre Dernière intervention 12 juin 2015 100
4 juin 2009 à 18:45
Salut,

Ca ne sert à rien de poster 3 fois le même problèmes !

Essai peut-être de mieux expliquer ton problème ...

Comment ton message d'erreur est généré ? par PHP ?
0
liliana23info Messages postés 8 Date d'inscription jeudi 4 juin 2009 Statut Membre Dernière intervention 4 juin 2009
4 juin 2009 à 18:50
mon message d'erreur est commsa
echo '<body onLoad="alert(\'you must answer  for all question first!\')">';
0
Dr Zoidberg Messages postés 529 Date d'inscription jeudi 28 juin 2007 Statut Membre Dernière intervention 12 juin 2015 100
4 juin 2009 à 18:54
Tu as du passer la valeur de tes bouton de ta première page vers le seconde qui test la validité et envoi éventuellement ce message (la page peut être la même).
Il te suffit de récrire le formulaire après l'écriture du message d'erreur en plaçant un CHECKED sur le bouton correspondant à la valeur transmise.

Désolé si je ne suis plus très clair à cette heure ci
0
liliana23info Messages postés 8 Date d'inscription jeudi 4 juin 2009 Statut Membre Dernière intervention 4 juin 2009
4 juin 2009 à 19:06
le problem c'est que je trouve pas la syntaxe correct j'ai fait sa
<input type="radio" name="q1" <?php if($q1==0) echo 'checked="checked"'; ?> value="0" >  <label for="q1">go</label>
  <input type="radio" name="q1" <?php if($q1==1) echo 'checked="checked"'; ?> value="1"   ><label for="q1">going</label>
  <input type="radio" name="q1" <?php if($q1==2) echo 'checked="checked"'; ?> value="2"  ><label for="q1">was</label>
  <input type="radio" name="q1"  <?php if($q1==3) echo 'checked="checked"'; ?>  value="3" ><label for="q1">went</label>
  <input type="radio" name="q1"  <?php if($q1==4) echo 'checked="checked"'; ?>  value="4" ><label for="q1">will go</label></li>  

ca c'est 5 repenses je doit choisir une si je valide sans rien choisir je recoi le message que je t'ai envoyé,un box,apres la selection que j'ai faire s'efface il n'est pas sauvgarder
0
liliana23info Messages postés 8 Date d'inscription jeudi 4 juin 2009 Statut Membre Dernière intervention 4 juin 2009
4 juin 2009 à 19:20
tu ma rependu?
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Dr Zoidberg Messages postés 529 Date d'inscription jeudi 28 juin 2007 Statut Membre Dernière intervention 12 juin 2015 100
4 juin 2009 à 21:59
Ca a l'air pas mal,

tu as bien fait un truc comme
if(isset($_GET['q1']))$q1=$_GET['q1'];
ou
if(isset($_POST['q1']))$q1=$_POST['q1'];

suivant la méthode utilisée par ton formulaire ?
0
liliana23info
5 juin 2009 à 00:55
salut j'ai fait commca
if(isset($_POST['q1']))$q1=$_POST['q1'];
il m'affich message d'erreur :Notice: Undefined index: q1 in C:\Program Files\EasyPHP 3.0\www\aaaaa\testniveau1.php on line 33

checked="checked" value="0" > go
0
liliana23info
5 juin 2009 à 01:07
aidez moi svp je suis perdu avec php
0
Dr Zoidberg Messages postés 529 Date d'inscription jeudi 28 juin 2007 Statut Membre Dernière intervention 12 juin 2015 100
5 juin 2009 à 08:20
Peux tu nous poster la ligne 33 et quelques lignes avant afin de mieux localiser le problème.
0
liliana23info
5 juin 2009 à 11:12
saut
voici un morceau du code:
<form action='traitniveau.php' method="post">
<i>
<h3><font face="arial" size="3" color="#2A0055"><i><b>welcom <?php session_start();echo $_SESSION['user'] ?> in this test<p>

Click on one answer for each question in this test
<p>
When you are finished, click on the "grade me!" button at the bottom of the page.
</b></i></font></h3></i>

<hr color="f55fd9" size="2">
            <i><font color="#2A0055" size="5">Choose the correct answer :</font></i>hey alic 
 <ol type="1">
    <li>Did you ……… anywhere interesting last weekend?

 <input type="radio" name="q1"  <?php if(isset($_POST['q1']))$q1=$_POST['q1']) echo 'checked="checked"'; ?> value="0"  >  <label for="q1">go</label>//ligne 33
   <input type="radio"  name="q1"  <?php if(isset($_POST['q1']))$q1=$_POST['q1']) echo 'checked="checked"'; ?> value="1" ><label for="q1">going</label>
   <input type="radio"  name="q1" <?php if(isset($_POST['q1']))$q1=$_POST['q1']) echo 'checked="checked"'; ?>  value="2"  ><label for="q1">was</label>
   <input type="radio"  name="q1" <?php if(isset($_POST['q1']))$q1=$_POST['q1']) echo 'checked="checked"'; ?> value="3"  ><label for="q1">went</label>
   <input type="radio" name="q1" <?php if(isset($_POST['q1']))$q1=$_POST['q1']) echo 'checked="checked"'; ?> value="4"  ><label for="q1">will go</label></li>    
<hr color="f55fd9" size ="2">
    <li>I think ……… taxi driver
         
         <input type="radio" value="1" name="q2"   ><label for="q2">she's a</label>
         <input type="radio" value="2" name="q2" ><label for="q2">her job is an</label>
         <input type="radio" value="3" name="q2" ><label for="q2"> she's</label>
         <input type="radio" value="4" name="q2" ><label for="q2">work in</label></li>
<hr color="f55fd9" size ="2">

ce sont deux question en(echo)
et les choix des repenses en boutouns radio
0
Dr Zoidberg Messages postés 529 Date d'inscription jeudi 28 juin 2007 Statut Membre Dernière intervention 12 juin 2015 100
5 juin 2009 à 11:23
remplace ta partie
 <input type="radio" name="q1"  <?php if(isset($_POST['q1']))$q1=$_POST['q1']) echo 'checked="checked"'; ?> value="0"  >  <label for="q1">go</label>//ligne 33
   <input type="radio"  name="q1"  <?php if(isset($_POST['q1']))$q1=$_POST['q1']) echo 'checked="checked"'; ?> value="1" ><label for="q1">going</label>
   <input type="radio"  name="q1" <?php if(isset($_POST['q1']))$q1=$_POST['q1']) echo 'checked="checked"'; ?>  value="2"  ><label for="q1">was</label>
   <input type="radio"  name="q1" <?php if(isset($_POST['q1']))$q1=$_POST['q1']) echo 'checked="checked"'; ?> value="3"  ><label for="q1">went</label>
   <input type="radio" name="q1" <?php if(isset($_POST['q1']))$q1=$_POST['q1']) echo 'checked="checked"'; ?> value="4"  ><label for="q1">will go</label></li> 

par exemple par
<?php 
if(isset($_POST['q1']))$q1=$_POST['q1']) ;
else $q1 = -1;
$check = 'checked="checked"';
?>

<input type="radio" name="q1"  <?php if($q1==0) echo $check; ?> value="0"  >  <label for="q1">go</label>//ligne 33
   <input type="radio"  name="q1"  <?php if($q1==1) echo $check; ?> value="1" ><label for="q1">going</label>
   <input type="radio"  name="q1" <?php if($q1==2) echo $check; ?>  value="2"  ><label for="q1">was</label>
   <input type="radio"  name="q1" <?php if($q1==3) echo $check; ?> value="3"  ><label for="q1">went</label>
   <input type="radio" name="q1" <?php if($q1==4) echo '$check; ?> value="4"  ><label for="q1">will go</label></li> 
0
liliana23info
5 juin 2009 à 11:26
MERCI JE VAIS ESSEYER
0
liliana23ino Messages postés 1 Date d'inscription vendredi 5 juin 2009 Statut Membre Dernière intervention 5 juin 2009
5 juin 2009 à 11:46
salut tu c'est s marcher que pour la premiére question
e les quesions qui suivent ne se sauvarde pas?
<form action='traitniveau.php' method="post">
<i>
<h3><font face="arial" size="3" color="#2A0055"><i><b>welcom <?php session_start();echo $_SESSION['user'] ?> in this test<p>

Click on one answer for each question in this test
<p>
When you are finished, click on the "grade me!" button at the bottom of the page.
</b></i></font></h3></i>

<hr color="f55fd9" size="2">
            <i><font color="#2A0055" size="5">Choose the correct answer :</font></i>hey alic 
 <ol type="1">
    <li>Did you ……… anywhere interesting last weekend?
<?php 
if(isset($_POST['q1'])) $q1=$_POST['q1'] ;
else $q1 = -1;
$check = 'checked="checked"';
?>

   <input type="radio" name="q1"  <?php if($q1==0) echo $check; ?> value="0"  >  <label for="q1">go</label>
   <input type="radio"  name="q1"  <?php if($q1==1) echo $check; ?> value="1" ><label for="q1">going</label>
   <input type="radio"  name="q1" <?php if($q1==2) echo $check; ?>  value="2"  ><label for="q1">was</label>
   <input type="radio"  name="q1" <?php if($q1==3) echo $check; ?> value="3"  ><label for="q1">went</label>
   <input type="radio" name="q1" <?php if($q1==4) echo $check; ?> value="4"  ><label for="q1">will go</label></li> 


    
<hr color="f55fd9" size ="2">
    <li>I think ……… taxi driver
<?php 
if(isset($_POST['q2'])) $q2=$_POST['q2'] ;
else $q2 = -1;
$check = 'checked="checked"';
?>	
         
         <input type="radio"  name="q2" <?php if($q2==0) echo $check; ?> value="0"  ><label for="q2">she's a</label>
         <input type="radio"  name="q2" <?php if($q2==1) echo $check; ?> value="1"><label for="q2">her job is an</label>
         <input type="radio"  name="q2" <?php if($q2==2) echo $check; ?> value="2" ><label for="q2"> she's</label>
         <input type="radio"  name="q2" <?php if($q2==3) echo $check; ?> value="3"><label for="q2">work in</label></li>
<hr color="f55fd9" size ="2">
    <li>I’m afraid I ……… here for your birthday party.
<?php 
if(isset($_POST['q3'])) $q3=$_POST['q3'] ;
else $q3 = -1;
$check = 'checked="checked"';
?>
         <input type="radio"  name="q3" <?php if($q3==0) echo $check; ?>  value="0" ><label for="q3">have not to be</label>
         <input type="radio"  name="q3" <?php if($q3==1) echo $check; ?> value="1" ><label for="q3">am not being</label>
         <input type="radio"  name="q3" <?php if($q3==2) echo $check; ?> value="2"  ><label for="q3">will be not</label>
         <input type="radio"  name="q3" <?php if($q3==3) echo $check; ?> value="3" ><label for="q3">can't be</label></li>
0