Bonjour a tous.
Jusque là, je pense m'être assez bien débrouillé, mais maintenant je suis bloqué.
Voilà, je dois faire un formulaire composé de 14 questions à trois réponses chacune.
En cliquant sur le bouton "Submit", les réponses doivent être comptées et rangées dans une base de données.
Par la suite, le professeur doit pouvoir accéder à ces données en se logant et l'admin peut ajouter un formulaire d'utilisateur.

Je vous poste les bouts de code que j'ai :

FORMULAIRE

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
<HTML><HEAD>
<SCRIPT>
var validateAnswers = new Array();
for(var i=0; i<8; i++)
{
	validateAnswers[i]=false;
}

function validateForm()
{
	var formOK = true;
	
	for(var i=0; i<8; i++)
	{
	if(validateAnswers[i]==false)
		{
			formOK = false;
			document.getElementById(i+"").style.background='red';
		}
	else 
		{
			document.getElementById(i+"").style.background='transparent';
		}
	}
	if(!formOK)
	{
		alert('You forgot to answer some questions!!');
	}

	return formOK;
}
</SCRIPT></HEAD>

<BODY><B>
<FONT SIZE=4>Learning Style Info </FONT></B> 
<FORM ACTION="http://157.***.**.**/Project/studentData.php" METHOD="POST" onSubmit="return validateForm();">

<TABLE HEIGHT="10%" WIDTH="40%">
  <TBODY>
  <HR>
  <TR>
    <TD>Name :</TD>
    <TD><INPUT NAME=student_name></TD></TR><TR>
    <TD>Class Group :</TD>
    <TD><SELECT SIZE=1 NAME=class_name>
		<OPTION> DCOM1 </OPTION>
		<OPTION> ITS1 </OPTION>
		<OPTION> ITM1 </OPTION>
		<OPTION> COM1 </OPTION>
		<OPTION> DNET1 </OPTION>
		<OPTION> EVCOM1 </OPTION></SELECT></TD><!--<TD></TD>--></TR>
</TBODY></TABLE>
<BR>


<TABLE BGCOLOR=aaaadd WIDTH=100%><TR><TD id="0">Question 1</TD></TR></TABLE>
<ol>
If I have to learn how to do something, I learn best when I:<BR>
<ul>
<INPUT TYPE=radio NAME=q1 VALUE="V" onclick="validateAnswers[0]=true">
Watch someone show me how<BR>
<INPUT TYPE=radio NAME=q1 VALUE="A" onclick="validateAnswers[0]=true">
Hear someone tell me how<BR>
<INPUT TYPE=radio NAME=q1 VALUE="K" onclick="validateAnswers[0]=true">
Try to do it myself
</ul></ol>


<TABLE BGCOLOR=aaaadd WIDTH=100%><TR><TD id="1">Question 2</TD></TR></TABLE>
<ol>
When I read, I often find that I:<BR>
<ul>
<INPUT TYPE=radio NAME=q2 VALUE="V" onclick="validateAnswers[1]=true">
Visualize what I am reading in my mind's eye<BR>
<INPUT TYPE=radio NAME=q2 VALUE="A" onclick="validateAnswers[1]=true">
Read out loud or hear the words inside my head<BR>
<INPUT TYPE=radio NAME=q2 VALUE="K" onclick="validateAnswers[1]=true">
Fidget and try to "feel" the content
</ul></ol>


<TABLE BGCOLOR=aaaadd WIDTH=100%><TR><TD id="2">Question 3</TD></TR></TABLE>
<ol>
When asked to give directions, I:<BR>
<ul>
<INPUT TYPE=radio NAME=q3 VALUE="V" onclick="validateAnswers[2]=true">
See the actual places in my mind as I say them or prefer to draw them<BR>
<INPUT TYPE=radio NAME=q3 VALUE="A" onclick="validateAnswers[2]=true">
Have no difficulty in giving them verbally<BR>
<INPUT TYPE=radio NAME=q3 VALUE="K" onclick="validateAnswers[2]=true">
Have to point or move my body as I give them
</ul></ol>


<TABLE BGCOLOR=aaaadd WIDTH=100%><TR><TD id="3">Question 4</TD></TR></TABLE>
<ol>
If I am unsure how to spell a word, I:<BR>
<ul>
<INPUT TYPE=radio NAME=q4 VALUE="V" onclick="validateAnswers[3]=true">
Write it in order to determine if it looks right<BR>
<INPUT TYPE=radio NAME=q4 VALUE="A" onclick="validateAnswers[3]=true">
Spell it out loud in order to determine if it sounds right<BR>
<INPUT TYPE=radio NAME=q4 VALUE="K" onclick="validateAnswers[3]=true">
Write it in order to determine if it feels right
</ul></ol>


<TABLE BGCOLOR=aaaadd WIDTH=100%><TR><TD id="4">Question 5</TD></TR></TABLE>
<ol>
When I write, I:<BR>
<ul>
<INPUT TYPE=radio NAME=q5 VALUE="V" onclick="validateAnswers[4]=true">
Am concerned how neat and well spaced my letters and words appear<BR>
<INPUT TYPE=radio NAME=q5 VALUE="A" onclick="validateAnswers[4]=true">
Often say the letters and words to myself<BR>
<INPUT TYPE=radio NAME=q5 VALUE="K" onclick="validateAnswers[4]=true">
Push hard on my pen or pencil and can feel the flow of the words or letters as I form them
</l></ol>


<TABLE BGCOLOR=aaaadd WIDTH=100%><TR><TD id="5">Question 6</TD></TR></TABLE>
<ol>
If I had to remember a list of items, I would remember it best if I:<BR>
<ul>
<INPUT TYPE=radio NAME=q6 VALUE="V" onclick="validateAnswers[5]=true">
Wrote them down<BR>
<INPUT TYPE=radio NAME=q6 VALUE="A" onclick="validateAnswers[5]=true">
Said them over and over to myself<BR>
<INPUT TYPE=radio NAME=q6 VALUE="K" onclick="validateAnswers[5]=true">
Moved around and used my fingers to name each item
</ul></ol>


<TABLE BGCOLOR=aaaadd WIDTH=100%><TR><TD id="6">Question 7</TD></TR></TABLE>
<ol>
I prefer teachers who:<BR>
<ul>
<INPUT TYPE=radio NAME=q7 VALUE="V" onclick="validateAnswers[6]=true">
Use the board or overhead projector while they lecture<BR>
<INPUT TYPE=radio NAME=q7 VALUE="A" onclick="validateAnswers[6]=true">
Talk with a lot of expression<BR>
<INPUT TYPE=radio NAME=q7 VALUE="K" onclick="validateAnswers[6]=true">
Use hands-on activities
</ul></ol>


<TABLE BGCOLOR=aaaadd WIDTH=100%><TR><TD id="7">Question 8</TD></TR></TABLE>
<ol>
When trying to concentrate, I have a difficult time when:<BR>
<ul>
<INPUT TYPE=radio NAME=q8 VALUE="V" onclick="validateAnswers[7]=true">
There is a lot of clutter or movement in the room<BR>
<INPUT TYPE=radio NAME=q8 VALUE="A" onclick="validateAnswers[7]=true">
There is a lot of noise in the room<BR>
<INPUT TYPE=radio NAME=q8 VALUE="K" onclick="validateAnswers[7]=true">
I have to sit still for any length of time
</ul></ol>


<TABLE BGCOLOR=aaaadd WIDTH=100%><TR><TD>&nbsp;</TD></TR></TABLE>
<CENTER>
<INPUT TYPE=submit><INPUT TYPE=reset>  </CENTER>
</FORM>

</BODY></HTML>

Studentdata.php

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  
 </HEAD>

 <BODY BGCOLOR=aaaadd>

<?php
	
	$conn = new mysqli('***.***.***.**','robert','toto','frenchie');

	if (mysqli_connect_errno() !=0){
		$message = mysqli_connect_error();
		echo $message;
	}
	else{

		echo "<p style=\"background:yellow\">Connected to the database!</p>"; 
	}

$aCount=0;
$vCount=0;
$kCount=0;

for($index = 1 ; $index < 9 ; $index++){
	if($_POST['question'.$index] == 'audio'){
		$aCount++;
	}
	if($_POST['question'.$index] == 'visual'){
		$vCount++;
	}
	if($_POST['question'.$index] == 'kinesthetic'){
		$kCount++;
	}
}

echo"Visual: $vCount; Auditory: $aCount; Kinesthetic: $kAcount";

$query_str = "INSERT INTO results (class_name,audio,visual,kinesthetic,student_name) VALUES('{$_POST['class_name']}' , '$aCount', '$vCount', '$kCount', '{$_POST['student_name']}'); ";

	$result = $conn->query($query_str);
	if ($result == FALSE){

		$errmsg = $conn->error;

		echo "<p>Query Failure: $errmsg</p>";
		$conn->close();
	}


?>
 
 </BODY>
</HTML>

Login.html

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
 </HEAD>

 <BODY>
  <FORM METHOD=Post ACTION="http://***.***.**.**/Project/tryLogin.php">
  <TABLE>
<TR>
	<TD>Username</TD>
	<TD><INPUT TYPE="text" NAME="username"></TD>     
</TR>
<TR>
	<TD>Password</TD>
	<TD><INPUT TYPE="text" NAME="password"></TD>     
</TR>
<TR>
	<TD></TD>
	<TD><INPUT TYPE="submit" VALUE="Login"></TD>     
</TR>

</TABLE>
  </FORM>
 </BODY>
</HTML>

tryLogin.php

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
<?php


$adminPassword = "test123";

$formPassword = $_POST['password'];
$formUsername = $_POST['username'];

if(($formUsername == "admin") && ($adminPassword == "test123")){
	
	echo"hello administrator";
	}

// Open database connection

else{
	$conn = new mysqli('***.***.**.**','robert','toto','frenchie');
	$query_str = "SELECT * FROM login WHERE name='$formUsername' and password='$formPassword';";
	$result = $conn->query($query_str); 
	
if($result->num_rows == 1){
	echo "Welcome to the system $formUsername";
}
else{	
	header ("Location: http://***.***.**.**/Project/login.html");
	exit;
}

?>

J'ai posté tout ce que j'avais. Merci d'avance