Als er niks wordt ingevuld?
Ik heb de volgende scripts:
Code (php)
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
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
<center>
<img src="img/successpong.gif"></img>
<form action="grade.php" method="post" id="quiz">
<h3>Hoe laat is het?</h3>
<img src="img/klok1.gif"></img>
<div>
<input type="radio" name="question-1-answers" id="question-1-answers-A" value="A" />
<label for="question-1-answers-A">A) Het is 1 uur</label>
</div>
<div>
<input type="radio" name="question-1-answers" id="question-1-answers-B" value="B" />
<label for="question-1-answers-B">B) Het is 2 uur</label>
</div>
<div>
<input type="radio" name="question-1-answers" id="question-1-answers-C" value="C" />
<label for="question-1-answers-C">C) Het is half 1</label>
</div>
<div>
<input type="radio" name="question-1-answers" id="question-1-answers-D" value="D" />
<label for="question-1-answers-D">D) Het is kwart over 1</label>
</div>
<h3>Hoe laat is het?</h3>
<img src="img/klok2.gif"></img>
<div>
<input type="radio" name="question-2-answers" id="question-2-answers-A" value="A" />
<label for="question-2-answers-A">A) Het is kwart over 3</label>
</div>
<div>
<input type="radio" name="question-2-answers" id="question-2-answers-B" value="B" />
<label for="question-2-answers-B">B) Het is half 2</label>
</div>
<div>
<input type="radio" name="question-2-answers" id="question-2-answers-C" value="C" />
<label for="question-2-answers-C">C) Het is kwart voor 3</label>
</div>
<div>
<input type="radio" name="question-2-answers" id="question-2-answers-D" value="D" />
<label for="question-2-answers-D">D) Het is kwart voor 2</label>
</div>
<h3>Hoe laat is het?</h3>
<img src="img/klok3.gif"></img>
<div>
<input type="radio" name="question-3-answers" id="question-3-answers-A" value="A" />
<label for="question-3-answers-A">A) Het is half 5</label>
</div>
<div>
<input type="radio" name="question-3-answers" id="question-3-answers-B" value="B" />
<label for="question-3-answers-B">B) Het is kwart voor 6</label>
</div>
<div>
<input type="radio" name="question-3-answers" id="question-3-answers-C" value="C" />
<label for="question-3-answers-C">C) Het is half 6</label>
</div>
<div>
<input type="radio" name="question-3-answers" id="question-3-answers-D" value="D" />
<label for="question-3-answers-D">D) Het is kwart over 5</label>
</div>
<h3>Hoe laat is het?</h3>
<img src="img/klok4.gif"></img>
<div>
<input type="radio" name="question-4-answers" id="question-4-answers-A" value="A" />
<label for="question-4-answers-A">A) Het is half 12 </label>
</div>
<div>
<input type="radio" name="question-4-answers" id="question-4-answers-B" value="B" />
<label for="question-4-answers-B">B) Het is 6 uur</label>
</div>
<div>
<input type="radio" name="question-4-answers" id="question-4-answers-C" value="C" />
<label for="question-4-answers-C">C) Het is 12 uur</label>
</div>
<div>
<input type="radio" name="question-4-answers" id="question-4-answers-D" value="D" />
<label for="question-4-answers-D">D) Het is kwart over 6</label>
</div>
<h3>Hoe laat is het?</h3>
<img src="img/klok5.gif"></img>
<div>
<input type="radio" name="question-5-answers" id="question-5-answers-A" value="A" />
<label for="question-5-answers-A">A) Het is kwart voor 10</label>
</div>
<div>
<input type="radio" name="question-5-answers" id="question-5-answers-B" value="B" />
<label for="question-5-answers-B">B) Het is 9 uur</label>
</div>
<div>
<input type="radio" name="question-5-answers" id="question-5-answers-C" value="C" />
<label for="question-5-answers-C">C) Het is kwart over 10</label>
</div>
<div>
<input type="radio" name="question-5-answers" id="question-5-answers-D" value="D" />
<label for="question-5-answers-D">D) Het is kwart voor 9</label>
</div>
<input type="submit" value="Verstuur je antwoorden!" />
</form>
</center>
Dit script stuurt door naar:
<?php
$answer1 = $_POST['question-1-answers'];
$answer2 = $_POST['question-2-answers'];
$answer3 = $_POST['question-3-answers'];
$answer4 = $_POST['question-4-answers'];
$answer5 = $_POST['question-5-answers'];
$answer6 = $_POST['question-6-answers'];
$totalCorrect = 0;
if ($answer1 == "A") { $totalCorrect++; }
if ($answer2 == "C") { $totalCorrect++; }
if ($answer3 == "D") { $totalCorrect++; }
if ($answer4 == "B") { $totalCorrect++; }
if ($answer5 == "A") { $totalCorrect++; }
if ($answer6) { $totalCorrect++; }
echo "<div id='results'> Je had er $totalCorrect goed!</div>";
?>
<img src="img/successpong.gif"></img>
<form action="grade.php" method="post" id="quiz">
<h3>Hoe laat is het?</h3>
<img src="img/klok1.gif"></img>
<div>
<input type="radio" name="question-1-answers" id="question-1-answers-A" value="A" />
<label for="question-1-answers-A">A) Het is 1 uur</label>
</div>
<div>
<input type="radio" name="question-1-answers" id="question-1-answers-B" value="B" />
<label for="question-1-answers-B">B) Het is 2 uur</label>
</div>
<div>
<input type="radio" name="question-1-answers" id="question-1-answers-C" value="C" />
<label for="question-1-answers-C">C) Het is half 1</label>
</div>
<div>
<input type="radio" name="question-1-answers" id="question-1-answers-D" value="D" />
<label for="question-1-answers-D">D) Het is kwart over 1</label>
</div>
<h3>Hoe laat is het?</h3>
<img src="img/klok2.gif"></img>
<div>
<input type="radio" name="question-2-answers" id="question-2-answers-A" value="A" />
<label for="question-2-answers-A">A) Het is kwart over 3</label>
</div>
<div>
<input type="radio" name="question-2-answers" id="question-2-answers-B" value="B" />
<label for="question-2-answers-B">B) Het is half 2</label>
</div>
<div>
<input type="radio" name="question-2-answers" id="question-2-answers-C" value="C" />
<label for="question-2-answers-C">C) Het is kwart voor 3</label>
</div>
<div>
<input type="radio" name="question-2-answers" id="question-2-answers-D" value="D" />
<label for="question-2-answers-D">D) Het is kwart voor 2</label>
</div>
<h3>Hoe laat is het?</h3>
<img src="img/klok3.gif"></img>
<div>
<input type="radio" name="question-3-answers" id="question-3-answers-A" value="A" />
<label for="question-3-answers-A">A) Het is half 5</label>
</div>
<div>
<input type="radio" name="question-3-answers" id="question-3-answers-B" value="B" />
<label for="question-3-answers-B">B) Het is kwart voor 6</label>
</div>
<div>
<input type="radio" name="question-3-answers" id="question-3-answers-C" value="C" />
<label for="question-3-answers-C">C) Het is half 6</label>
</div>
<div>
<input type="radio" name="question-3-answers" id="question-3-answers-D" value="D" />
<label for="question-3-answers-D">D) Het is kwart over 5</label>
</div>
<h3>Hoe laat is het?</h3>
<img src="img/klok4.gif"></img>
<div>
<input type="radio" name="question-4-answers" id="question-4-answers-A" value="A" />
<label for="question-4-answers-A">A) Het is half 12 </label>
</div>
<div>
<input type="radio" name="question-4-answers" id="question-4-answers-B" value="B" />
<label for="question-4-answers-B">B) Het is 6 uur</label>
</div>
<div>
<input type="radio" name="question-4-answers" id="question-4-answers-C" value="C" />
<label for="question-4-answers-C">C) Het is 12 uur</label>
</div>
<div>
<input type="radio" name="question-4-answers" id="question-4-answers-D" value="D" />
<label for="question-4-answers-D">D) Het is kwart over 6</label>
</div>
<h3>Hoe laat is het?</h3>
<img src="img/klok5.gif"></img>
<div>
<input type="radio" name="question-5-answers" id="question-5-answers-A" value="A" />
<label for="question-5-answers-A">A) Het is kwart voor 10</label>
</div>
<div>
<input type="radio" name="question-5-answers" id="question-5-answers-B" value="B" />
<label for="question-5-answers-B">B) Het is 9 uur</label>
</div>
<div>
<input type="radio" name="question-5-answers" id="question-5-answers-C" value="C" />
<label for="question-5-answers-C">C) Het is kwart over 10</label>
</div>
<div>
<input type="radio" name="question-5-answers" id="question-5-answers-D" value="D" />
<label for="question-5-answers-D">D) Het is kwart voor 9</label>
</div>
<input type="submit" value="Verstuur je antwoorden!" />
</form>
</center>
Dit script stuurt door naar:
<?php
$answer1 = $_POST['question-1-answers'];
$answer2 = $_POST['question-2-answers'];
$answer3 = $_POST['question-3-answers'];
$answer4 = $_POST['question-4-answers'];
$answer5 = $_POST['question-5-answers'];
$answer6 = $_POST['question-6-answers'];
$totalCorrect = 0;
if ($answer1 == "A") { $totalCorrect++; }
if ($answer2 == "C") { $totalCorrect++; }
if ($answer3 == "D") { $totalCorrect++; }
if ($answer4 == "B") { $totalCorrect++; }
if ($answer5 == "A") { $totalCorrect++; }
if ($answer6) { $totalCorrect++; }
echo "<div id='results'> Je had er $totalCorrect goed!</div>";
?>
Maar als men niks invult krijg ik een foutmelding. Hoe kan ik dit voorkomen? Dat als ze niks hebben ingevult ze alsnog iets moeten invullen.
Alvast bedankt
Gelieve in het vervolg bij code, code tags te gebruiken.[/modedit]
Gewijzigd op 04/11/2010 23:40:28 door Bas IJzelendoorn
Code (php)
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
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
Heel simpel
Waar moet ik dat tussen zetten?
Het zit niet echt mooi in elkaar op moment. Probeer wat meer met arrays te werken. Dat scheelt je heel veel typ werk.
Kan niet koieren op ipod anders had ik dat eventjes fedaan