Probleme textarea dans formulaire php/mysql
Bonjour, je suis entrain de realiser un questionnaire dynamique en php/mysql
dans l'interface d'ajout j'ai un probleme , je veut recuperer les possibilités de reponse dans un champs textarea chaque ligne contient une possibilté et après je veut que ses valeurs s'enregistre dans la table reponse chaqu'une dans un enregistrement mais j'ai pas trouvé la solution .
c'est la pge de formulaire d'ajout:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><head>
<link type="text/css" rel="StyleSheet" href="admin/style.css">
<title>
Questionnaire E-Learning
</title>
<script type="text/javascript">
function THEFUNCTION(i) {
var choix1 = document.getElementById('choix1');
switch(i) {
case 0 : choix1.style.display = '';
choix2.style.display = 'none';
break;
case 1 : choix2.style.display = '';
choix1.style.display = 'none';
break;
default: choix1.style.display = 'none';
choix2.style.display = 'none';
break;
}
}
</script>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body bgcolor='#0099CC' link='#000080' vlink='#000080' alink='#FFFF00'><font face='verdana' size='2'>
<table width='95%' align='center' style='border-collapse: collapse' bordercolor='#0A47FF' bgcolor='#E5F9FF' border='1' cellspacing='0'>
<tr>
<td>
<form action="traitementadd.php" name="form_add" method="post" class="formulaire"><!-- START THE SURVEY -->
<table width='100%' align='center' cellspacing='0' cellpadding='2'>
<tr>
<td align='center' bgcolor='#E5F9FF'><font size='5' color='#0A47FF'><b>Questionnaire Evaluation de la Qualité du Processus dApprentissage dun cours en ligne</b></font><br />
<font size='2' color='#111111'>Software Engineering Group<br>Departement informatique<br> Institut Superieur de gestion
</td>
</tr>
<tr>
<td align='center' bgcolor='#0099CC' valign='middle'>
</td>
</tr>
</table>
<!-- START THE GROUP -->
<table width='99%' align='center' border='0' bgcolor='#FFFFFF'>
<tr>
<td align='center'>
<font face='verdana' size='3' color='#0A47FF'><b><br />La satisfaction de lapprenant </b></font>
<!-- PRESENT THE QUESTIONS -->
<!-- NEW QUESTION -->
<div id='question123'>
<table width='75%' align='center' border='1' style='border-collapse: collapse' bordercolor='#0099CC' bgcolor='white'>
<tr>
<td align='center'>
<table width='100%' cellspacing='0'>
<tr>
<td align='center' bgcolor='#E5F9FF'>
<font size='2' color='#0033CC'><b><label for='5X21X123'>Ajouter une question<b></label></b></td>
</tr>
<tr>
<td align='center'>
<table class='question'>
<td align="center" class="answertext">Categorie :</td>
<td>
<select name="categories" id="categories" size="1">
<option name="" value="0"></option>
<?php
include("connect.php");
mysql_query("SET NAMES UTF8");
$sql="SELECT *
FROM categorie";
$req=mysql_query($sql)
or die('Erreur SQL !
'.$sql.'
'.mysql_error());
while($resultat=mysql_fetch_assoc($req))
{
$id_categorie=$resultat['id_categorie'];
$libelle_cat=$resultat['libelle_cat'];
echo '<option value="'.$id_categorie.'">'.$libelle_cat; }
?>
</option>
</select> <br /> </td>
</tr>
<tr>
<td align="center" class="answertext">Libellé question :</td>
<td><input type="text" id="libelle_quest" name="libelle_quest"/>
<br />
</td>
</tr>
<tr>
<td align="center" class="answertext">Name:</td>
<td><input type="text" id="Name" name="Name"/>
<br />
</td>
</tr>
<tr>
<td align="center" class="answertext">Réponse :</td>
<td><select name="type" id="type" onChange="THEFUNCTION(this.selectedIndex);">
<option value="Multichoix">Multichoix</option>
<option value="choix unique">Choix unique</option>
<option value="champs texte">Champs texte</option>
</select> <br />
</td>
</tr>
<tr>
<td align="center" class="answertext">Réponse :</td>
<td><div style="display:none;" id="choix1">
<label for="Multichoix">Multichoix: </label>
<textarea name="Multichoix" id="Multichoix" ></textarea>
</div>
<div style="display:none;" id="choix2">
<label for="choix_unique">choix unique:</label>
<textarea name="choix_unique" id="choix_unique"></textarea>
</div>
</td>
</tr>
<td> </td>
</tr>
</table></td>
</tr>
<tr>
<td align='center' bgcolor='#E5F9FF'>
<font size='1'></font>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table>
<tr>
<td height='1'></td>
</tr>
</table>
</div>
<!-- END THE GROUP -->
</td>
</tr>
</table>
<table><tr><td height='2'></td></tr></table>
<!-- PRESENT THE NAVIGATOR -->
<table width='100%' align='center' bgcolor='#E5F9FF'>
<tr>
<td width="50%" height="40" align='center' valign='middle'><input class='submit' type='submit' value=' Ajouter' name='move2' accesskey="s"/></td>
</tr>
</table>
<!-- group2.php -->
</form>
</td>
</tr>
</table>
<table width='95%' align='center' style='border-collapse: collapse' bordercolor='#333333' bgcolor='#0099CC' border='0' cellspacing='0'>
<tr>
<!-- <td align='right'><font size='2'> -->
<!-- Adopted from <a href='http://www.phpsurveyor.org/' target='_blank'>PHPSurveyor</a> -->
<!-- </td> -->
</tr>
</table>
</body>
</html> |
Le code de traitement de formulaire
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Ajout d'une question</title>
</head>
<body>
<?php
include("connect.php");
mysql_query("SET NAMES UTF8");
$id_categorie=$_POST["categories"];
$libelle_quest=$_POST["libelle_quest"];
$type=$_POST["type"];
$sql1 = "INSERT INTO question
(id_categorie,libelle_quest,type)
VALUES
('$id_categorie','$libelle_quest','$type') ;";
mysql_query($sql1) or die('Erreur SQL !
'.$sql1.'
'.mysql_error());
if(mysql_query($sql1) )
$id_question = mysql_insert_id();
if($type=="Multichoix")
{
$reponse=$_POST["Multichoix"];
explode("/n",$reponse);
}
if($type=="choix unique"){
$reponse=$_POST["choix_unique"];
explode("/n",$reponse);
}
echo $reponse;
$sql2 = "INSERT INTO reponse
(libelle_rep,id_question)
VALUES
('$reponse','$id_question') ;";
mysql_query($sql2) or die('Erreur SQL !
'.$sql2.'
'.mysql_error());
header('location:questions.php');
?>
</body>
</html> |
SVP ,pouvez vous m'aidez