Kan iemand mij helpen met dit scrit.
Zou iemand mij kunnen vertellen wat er fout aan is want ik kan hem niet vinden of ik kijk er gewoon overheen.
Script:
<link href="CSS/styleindex.css" rel="stylesheet" type="text/css" />
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
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<?php
include "config.php";
echo"<br><center><strong>Vul hier de velden in om uw te registreren.</strong><br><b>
De velden met een * zijn <u>verplicht</u>.</b></center>";
echo"
<form action=home.php target=_parent method=POST>
<table align=center class=tabelinhoud><br><br>
<tr>
<td>
<b>*Naam:</b>
</td>
<td>
<input type=text name=\"naam\" value=\"".htmlentities($_POST["naam"])."\">
</td>
</tr>
<tr>
<td>
<b>*Achternaam:</b>
</td>
<td>
<input type=text name=\"achternaam\" value=\"".htmlentities($_POST["achternaam"])."\">
</td>
</tr>
<tr>
<td>
<b>*Woon Plaats:</b>
</td>
<td>
<input type=text name=\"plaats\" value=\"".htmlentities($_POST["plaats"])."\">
</td>
</tr>
<tr>
<td>
<b>Telefoon nummer:</b>
</td>
<td>
<input type=text name=\"tel\" value=\"".htmlentities($_POST["tel"])."\">
</td>
</tr>
<tr>
<td>
<b>*E-Mail:</b>
</td>
<td>
<input type=text name=\"mail\" value=\"".htmlentities($_POST["mail"])."\">
</td>
</tr>
<tr>
<td>
<b>Geslacht:</b>
</td>
<td>
<select name=\"sexe\" value=\"".htmlentities($_POST["sexe"])."\">
<option name=\"man\" value=\"".htmlentities($_POST["man"])."\">Man</option>
<option name=\"vrouw\" value=\"".htmlentities($_POST["vrouw"])."\">Vrouw</option>
</select>
</td>
</tr>
<tr>
<td>
<b>*Geboorte Datum:</b>
</td>
<td>
<select name=\"gdatum\" value=\"gdatum\">
<option name=\"1\">1</option>
<option name=\"2\">2</option>
<option name=\"3\">3</option>
<option name=\"4\">4</option>
<option name=\"5\">5</option>
<option name=\"6\">6</option>
<option name=\"7\">7</option>
<option name=\"8\">8</option>
<option name=\"9\">9</option>
<option name=\"10\">10</option>
<option name=\"11\">11</option>
<option name=\"12\">12</option>
<option name=\"13\">13</option>
<option name=\"14\">14</option>
<option name=\"15\">15</option>
<option name=\"16\">16</option>
<option name=\"17\">17</option>
<option name=\"18\">18</option>
<option name=\"19\">19</option>
<option name=\"20\">20</option>
<option name=\"21\">21</option>
<option name=\"22\">22</option>
<option name=\"23\">23</option>
<option name=\"24\">24</option>
<option name=\"25\">25</option>
<option name=\"26\">26</option>
<option name=\"27\">27</option>
<option name=\"28\">28</option>
<option name=\"29\">29</option>
<option name=\"30\">30</option>
<option name=\"31\">31</option>
</select>
<select name=\"gdatum\" value=\"gdatum\">
<option name=\"January\">January</option>
<option name=\"Feberuary\">Feberuary</option>
<option name=\"Maart\">Maart</option>
<option name=\"April\">April</option>
<option name=\"Mei\">Mei</option>
<option name=\"Juni\">Juni</option>
<option name=\"July\">July</option>
<option name=\"Augustus\">Augustus</option>
<option name=\"September\">September</option>
<option name=\"Oktober\">Oktober</option>
<option name=\"November\">November</option>
<option name=\"December\">December</option>
</select>
<select name=\"gdatum\" value=\"gdatum\">
<option name=\"1950\">1950</option>
<option name=\"1951\">1951</option>
<option name=\"1952\">1952</option>
<option name=\"1953\">1953</option>
<option name=\"1954\">1954</option>
<option name=\"1955\">1955</option>
<option name=\"1956\">1956</option>
<option name=\"1957\">1957</option>
<option name=\"1958\">1958</option>
<option name=\"1959\">1959</option>
<option name=\"1960\">1960</option>
<option name=\"1961\">1961</option>
<option name=\"1962\">1962</option>
<option name=\"1963\">1963</option>
<option name=\"1964\">1964</option>
<option name=\"1965\">1965</option>
<option name=\"1966\">1966</option>
<option name=\"1967\">1967</option>
<option name=\"1968\">1968</option>
<option name=\"1969\">1969</option>
<option name=\"1970\">1970</option>
<option name=\"1971\">1971</option>
<option name=\"1971\">1972</option>
<option name=\"1971\">1973</option>
<option name=\"1971\">1974</option>
<option name=\"1971\">1975</option>
<option name=\"1971\">1976</option>
<option name=\"1971\">1977</option>
<option name=\"1971\">1978</option>
<option name=\"1971\">1979</option>
<option name=\"1980\">1980</option>
<option name=\"1970\">1981</option>
<option name=\"1981\">1981</option>
<option name=\"1982\">1982</option>
<option name=\"1983\">1983</option>
<option name=\"1984\">1984</option>
<option name=\"1985\">1985</option>
<option name=\"1986\">1986</option>
<option name=\"1987\">1987</option>
<option name=\"1988\">1988</option>
<option name=\"1989\">1989</option>
<option name=\"1990\">1990</option>
<option name=\"1991\">1991</option>
<option name=\"1992\">1992</option>
<option name=\"1993\">1993</option>
<option name=\"1994\">1994</option>
<option name=\"1995\">1995</option>
<option name=\"1996\">1996</option>
<option name=\"1997\">1997</option>
<option name=\"1998\">1998</option>
<option name=\"1999\">1999</option>
<option name=\"2000\">2000</option>
</select>
</td>
</tr>
<tr>
<td>
<b>*Username:</b>
</td>
<td>
<input type=text name=\"username\" value=\"".htmlentities($_POST["username"])."\">
</td>
</tr>
<tr>
<td>
<b>*Password:</b>
</td>
<td>
<input type=password name=\"password\" value=\"".htmlentities($_POST["password"])."\">
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type=submit name=\"registreer\" value=\"submit\">
</td>
</tr>
</table>
</form> ";
if (isset($_POST['registreer']))
{ // Begin A
$fout = $_GET['fout'];
if ($fout == "naam") { echo "<br><font color=red><b>U moet Uw naam nog invullen.</b>"; }
elseif ($fout == "achternaam") {echo "<br><font color=red><b>U moet Uw achternaam nog invullen.</b>";}
elseif ($fout == "plaats") {echo "<br><font color=red><b>U moet Uw woon plaats nog invullen.</b>";}
elseif ($fout == "mail") {echo "<br><font color=red><b>U moet Uw E-mail nog invullen.</b>";}
elseif ($fout == "username") {echo "<br><font color=red><b>U moet Uw username nog invullen.</b>";}
elseif ($fout == "password") {echo "<br><font color=red><b>U moet Uw wachtwoord nog invullen.</b>";}
$query2 = "SELECT * FROM user WHERE USERNAME = $username";
$result2 = mysql_db_query("$dbname",$query2);
while ($r2 = mysql_fetch_array($result2))
{ // Begin B
$username = $r2['USERNAME'];
} //Eind B
if ($username == $username) { echo"<font color=red><b>FOUT</b></font><br>Deze Username bestaat al!";}
else { //Begin C
$query = "INSERT INTO `user`(NAAM, ACHTERNAAM, PLAATS, TEL, MAIL, SEXE, GDATUM, USERNAME, PASSWORD)
VALUES ('$naam', '$achternaam', '$plaats', '$tel', '$mail', '$sexe', '$gdatum', '$username', '$password')";
mysql_db_query("$dbname",$query);
$naam = $_POST['naam'];
$achternaam = $_POST['achternaam'];
$mail = $_POST['mail'];
$tel = $_POST['tel'];
$username = $_POST['username'];
$password = md5($_POST['password']);
$plaats = $_POST['plaats'];
$gdatum = $_POST['gdatum'];
$sexe = $_POST['sexe'];
} //Eind C
} //Eind A
?>
include "config.php";
echo"<br><center><strong>Vul hier de velden in om uw te registreren.</strong><br><b>
De velden met een * zijn <u>verplicht</u>.</b></center>";
echo"
<form action=home.php target=_parent method=POST>
<table align=center class=tabelinhoud><br><br>
<tr>
<td>
<b>*Naam:</b>
</td>
<td>
<input type=text name=\"naam\" value=\"".htmlentities($_POST["naam"])."\">
</td>
</tr>
<tr>
<td>
<b>*Achternaam:</b>
</td>
<td>
<input type=text name=\"achternaam\" value=\"".htmlentities($_POST["achternaam"])."\">
</td>
</tr>
<tr>
<td>
<b>*Woon Plaats:</b>
</td>
<td>
<input type=text name=\"plaats\" value=\"".htmlentities($_POST["plaats"])."\">
</td>
</tr>
<tr>
<td>
<b>Telefoon nummer:</b>
</td>
<td>
<input type=text name=\"tel\" value=\"".htmlentities($_POST["tel"])."\">
</td>
</tr>
<tr>
<td>
<b>*E-Mail:</b>
</td>
<td>
<input type=text name=\"mail\" value=\"".htmlentities($_POST["mail"])."\">
</td>
</tr>
<tr>
<td>
<b>Geslacht:</b>
</td>
<td>
<select name=\"sexe\" value=\"".htmlentities($_POST["sexe"])."\">
<option name=\"man\" value=\"".htmlentities($_POST["man"])."\">Man</option>
<option name=\"vrouw\" value=\"".htmlentities($_POST["vrouw"])."\">Vrouw</option>
</select>
</td>
</tr>
<tr>
<td>
<b>*Geboorte Datum:</b>
</td>
<td>
<select name=\"gdatum\" value=\"gdatum\">
<option name=\"1\">1</option>
<option name=\"2\">2</option>
<option name=\"3\">3</option>
<option name=\"4\">4</option>
<option name=\"5\">5</option>
<option name=\"6\">6</option>
<option name=\"7\">7</option>
<option name=\"8\">8</option>
<option name=\"9\">9</option>
<option name=\"10\">10</option>
<option name=\"11\">11</option>
<option name=\"12\">12</option>
<option name=\"13\">13</option>
<option name=\"14\">14</option>
<option name=\"15\">15</option>
<option name=\"16\">16</option>
<option name=\"17\">17</option>
<option name=\"18\">18</option>
<option name=\"19\">19</option>
<option name=\"20\">20</option>
<option name=\"21\">21</option>
<option name=\"22\">22</option>
<option name=\"23\">23</option>
<option name=\"24\">24</option>
<option name=\"25\">25</option>
<option name=\"26\">26</option>
<option name=\"27\">27</option>
<option name=\"28\">28</option>
<option name=\"29\">29</option>
<option name=\"30\">30</option>
<option name=\"31\">31</option>
</select>
<select name=\"gdatum\" value=\"gdatum\">
<option name=\"January\">January</option>
<option name=\"Feberuary\">Feberuary</option>
<option name=\"Maart\">Maart</option>
<option name=\"April\">April</option>
<option name=\"Mei\">Mei</option>
<option name=\"Juni\">Juni</option>
<option name=\"July\">July</option>
<option name=\"Augustus\">Augustus</option>
<option name=\"September\">September</option>
<option name=\"Oktober\">Oktober</option>
<option name=\"November\">November</option>
<option name=\"December\">December</option>
</select>
<select name=\"gdatum\" value=\"gdatum\">
<option name=\"1950\">1950</option>
<option name=\"1951\">1951</option>
<option name=\"1952\">1952</option>
<option name=\"1953\">1953</option>
<option name=\"1954\">1954</option>
<option name=\"1955\">1955</option>
<option name=\"1956\">1956</option>
<option name=\"1957\">1957</option>
<option name=\"1958\">1958</option>
<option name=\"1959\">1959</option>
<option name=\"1960\">1960</option>
<option name=\"1961\">1961</option>
<option name=\"1962\">1962</option>
<option name=\"1963\">1963</option>
<option name=\"1964\">1964</option>
<option name=\"1965\">1965</option>
<option name=\"1966\">1966</option>
<option name=\"1967\">1967</option>
<option name=\"1968\">1968</option>
<option name=\"1969\">1969</option>
<option name=\"1970\">1970</option>
<option name=\"1971\">1971</option>
<option name=\"1971\">1972</option>
<option name=\"1971\">1973</option>
<option name=\"1971\">1974</option>
<option name=\"1971\">1975</option>
<option name=\"1971\">1976</option>
<option name=\"1971\">1977</option>
<option name=\"1971\">1978</option>
<option name=\"1971\">1979</option>
<option name=\"1980\">1980</option>
<option name=\"1970\">1981</option>
<option name=\"1981\">1981</option>
<option name=\"1982\">1982</option>
<option name=\"1983\">1983</option>
<option name=\"1984\">1984</option>
<option name=\"1985\">1985</option>
<option name=\"1986\">1986</option>
<option name=\"1987\">1987</option>
<option name=\"1988\">1988</option>
<option name=\"1989\">1989</option>
<option name=\"1990\">1990</option>
<option name=\"1991\">1991</option>
<option name=\"1992\">1992</option>
<option name=\"1993\">1993</option>
<option name=\"1994\">1994</option>
<option name=\"1995\">1995</option>
<option name=\"1996\">1996</option>
<option name=\"1997\">1997</option>
<option name=\"1998\">1998</option>
<option name=\"1999\">1999</option>
<option name=\"2000\">2000</option>
</select>
</td>
</tr>
<tr>
<td>
<b>*Username:</b>
</td>
<td>
<input type=text name=\"username\" value=\"".htmlentities($_POST["username"])."\">
</td>
</tr>
<tr>
<td>
<b>*Password:</b>
</td>
<td>
<input type=password name=\"password\" value=\"".htmlentities($_POST["password"])."\">
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type=submit name=\"registreer\" value=\"submit\">
</td>
</tr>
</table>
</form> ";
if (isset($_POST['registreer']))
{ // Begin A
$fout = $_GET['fout'];
if ($fout == "naam") { echo "<br><font color=red><b>U moet Uw naam nog invullen.</b>"; }
elseif ($fout == "achternaam") {echo "<br><font color=red><b>U moet Uw achternaam nog invullen.</b>";}
elseif ($fout == "plaats") {echo "<br><font color=red><b>U moet Uw woon plaats nog invullen.</b>";}
elseif ($fout == "mail") {echo "<br><font color=red><b>U moet Uw E-mail nog invullen.</b>";}
elseif ($fout == "username") {echo "<br><font color=red><b>U moet Uw username nog invullen.</b>";}
elseif ($fout == "password") {echo "<br><font color=red><b>U moet Uw wachtwoord nog invullen.</b>";}
$query2 = "SELECT * FROM user WHERE USERNAME = $username";
$result2 = mysql_db_query("$dbname",$query2);
while ($r2 = mysql_fetch_array($result2))
{ // Begin B
$username = $r2['USERNAME'];
} //Eind B
if ($username == $username) { echo"<font color=red><b>FOUT</b></font><br>Deze Username bestaat al!";}
else { //Begin C
$query = "INSERT INTO `user`(NAAM, ACHTERNAAM, PLAATS, TEL, MAIL, SEXE, GDATUM, USERNAME, PASSWORD)
VALUES ('$naam', '$achternaam', '$plaats', '$tel', '$mail', '$sexe', '$gdatum', '$username', '$password')";
mysql_db_query("$dbname",$query);
$naam = $_POST['naam'];
$achternaam = $_POST['achternaam'];
$mail = $_POST['mail'];
$tel = $_POST['tel'];
$username = $_POST['username'];
$password = md5($_POST['password']);
$plaats = $_POST['plaats'];
$gdatum = $_POST['gdatum'];
$sexe = $_POST['sexe'];
} //Eind C
} //Eind A
?>
Alvast bedankt,
Verder is het meestal wel gemakkelijk om te weten WAT er fout gaat, aangezien ik mijn glazen bol kwijt ben (eerst kapot laten vallen, nieuwe gekocht en nu al weer kwijt...)
Code (php)
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
<?php
$naam = $_POST['naam'];
$achternaam = $_POST['achternaam'];
$mail = $_POST['mail'];
$tel = $_POST['tel'];
$username = $_POST['username'];
$password = md5($_POST['password']);
$plaats = $_POST['plaats'];
$gdatum = $_POST['gdatum'];
$sexe = $_POST['sexe'];
?>
$naam = $_POST['naam'];
$achternaam = $_POST['achternaam'];
$mail = $_POST['mail'];
$tel = $_POST['tel'];
$username = $_POST['username'];
$password = md5($_POST['password']);
$plaats = $_POST['plaats'];
$gdatum = $_POST['gdatum'];
$sexe = $_POST['sexe'];
?>
Hier zou ik wel even wat controles toepassen...
Ik dnk dat de fout hem zit in de Query want hij voegt niks toe in de database en mijn veldcontrolles niet uit maar dat komt misschien omdat de query niet goed word uitgevoerd...
Pas nadat je de sql gemaakt hebt, ga je die variabelen zoals $naam, $tel, $sexe e.d. aanmaken... maar daarna gebruik je ze niet meer...
Oftewel, je moet eerst je variabelen aanmaken voordat je ze kan gebruiken.
Dus zet
Code (php)
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
<?php
$naam = $_POST['naam'];
$achternaam = $_POST['achternaam'];
$mail = $_POST['mail'];
$tel = $_POST['tel'];
$username = $_POST['username'];
$password = md5($_POST['password']);
$plaats = $_POST['plaats'];
$gdatum = $_POST['gdatum'];
$sexe = $_POST['sexe'];
?>
$naam = $_POST['naam'];
$achternaam = $_POST['achternaam'];
$mail = $_POST['mail'];
$tel = $_POST['tel'];
$username = $_POST['username'];
$password = md5($_POST['password']);
$plaats = $_POST['plaats'];
$gdatum = $_POST['gdatum'];
$sexe = $_POST['sexe'];
?>
boven
Code (php)
1
2
3
4
5
6
2
3
4
5
6
<?php
$sql = "INSERT INTO `user`(NAAM, ACHTERNAAM, PLAATS, TEL, MAIL, SEXE, GDATUM, USERNAME, PASSWORD)
VALUES ('$naam', '$achternaam', '$plaats', '$tel', '$mail', '$sexe', '$gdatum', '$username', '$password')";
mysql_query(,$sql);
?>
$sql = "INSERT INTO `user`(NAAM, ACHTERNAAM, PLAATS, TEL, MAIL, SEXE, GDATUM, USERNAME, PASSWORD)
VALUES ('$naam', '$achternaam', '$plaats', '$tel', '$mail', '$sexe', '$gdatum', '$username', '$password')";
mysql_query(,$sql);
?>
Edit:
Waarom gebruik je niet gewoon mysql_query() ?
en je moet ook even goede benamingen geven aan je variabelen
$sql = "INSERT.... bla";
$result = mysql_query();
Waarom gebruik je niet gewoon mysql_query() ?
en je moet ook even goede benamingen geven aan je variabelen
$sql = "INSERT.... bla";
$result = mysql_query();
Gewijzigd op 01/01/1970 01:00:00 door Arian Stolwijk
Code (php)
De datum die jij in de database zet, is overigens géén datum! Daar kun je dus niets meer mee. Zorg er voor dat een datum in een DATE komt te staan, in het formaat yyyy-mm-dd. Ieder ander formaat is gewoon fout en levert vroeg of laat problemen op.
Tip: Ga geen grote lappen html-code echoen, dat maakt de boel onnodig langzaam en het is lastiger te coden.
PHP gebruik je voor een dynamische website, maar de site dan ook dynamisch, bv. de selectboxen zoals ik hierboven heb beschreven. Maakt de boel een stuk eenvoudiger.