De volgende code gebruik ik.
Nu heb ik deze code vanuit een ander script van mij overgenomen, die overigens wel werkt. Hierbij heb ik alleen de namen van scripts verander en het form.
Als ik dit script wil verwerken dan krijg ik
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Mobiel toestel toevoegen</title> </head> <body> <?php include ("sql_connect.php"); echo (" <form action=\"$php_self\" method=\"post\" enctype=\"multipart/form-data\"> <input type=\"hidden\" name=\"fax_state\" value=\"ja\"> <input type=\"hidden\" name=\"submit\" value=\"ja\"> <table cellspacing=\"2\" cellpadding=\"2\" border=\"0\"> <tr> <td>Naam:</td> <td> <select name=\"name\"> <option>Kies naam</option> <option value=\"Naam 1\"");if ("$name" == "Naam 1"){echo ("selected");}echo(">Naam 1</option> <option value=\"Naam 2\"");if ("$name" == "Naam 2"){echo ("selected");}echo(">Naam 2</option> <option value=\"Naam 3\"");if ("$name" == "Naam 3"){echo ("selected");}echo(">Naam 3</option> </select> </td> </tr> <tr> <td>Merk:</td> <td> <select name=\"fax_brand\"> <option>Kies merk</opion> <option value=\"Brother\"");if ("$fax_brand" == "Brother"){echo ("selected");}echo(">Brother</option> <option value=\"Ricoh\"");if ("$fax_brand" == "Ricoh"){echo ("selected");}echo(">Ricoh</option> </select> </td> </tr> <tr> <td>Type:</td> <td> <input type=\"text\" value=\"$fax_type\" name=\"fax_type\"> </td> </tr> <tr> <td>Afbeelding:</td> <td> <input type='file' name='Bijlage' size=30> </td> </tr> <tr> <td>Papierformaat:</td> <td> <select name=\"fax_paper\"> <option value=\"A4\"");if ("$fax_paper" == "A4"){echo("selected");}echo(">A4</option> <option value=\"A3, A4\"");if ("$fax_paper" == "A3, A4"){echo("selected");}echo(">A3, A4</option> <option value=\"A3, A4, A5\"");if ("$fax_paper" == "A3, A4, A5"){echo("selected");}echo(">A3, A4, A5</option> </select> </td> </tr> <tr> <td>Papiercassette:</td> <td> <input type=\"text\" value=\"$fax_cassette\" name=\"fax_cassette\"> Vel </td> </tr> <tr> <td>Afdruksnelheid:</td> <td> <input type=\"text\" value=\"$fax_afdruksnelheid\" name=\"fax_afdruksnelheid\"> pagina's per minuut </td> </tr> <tr> <td>Geheugen:</td> <td> <input type=\"text\" value=\"$fax_memory\" name=\"fax_memory\"> MB </td> </tr> <tr> <td>Modemsnelheid:</td> <td> <input type=\"text\" value=\"$fax_modem\" name=\"fax_modem\"> bps </td> </tr> <tr> <td>Kleur:</td> <td> <input type=\"radio\" value=\"ja\" name=\"fax_kleur\""); if("$fax_kleur" == "ja"){echo("checked");}echo("> ja <input type=\"radio\" value=\"nee\" name=\"fax_kleur\""); if("$fax_kleur" == "nee"){echo("checked");}echo("> nee </td> </tr> <tr> <td>Laser:</td> <td> <input type=\"radio\" value=\"ja\" name=\"fax_laser\""); if("$fax_laser" == "ja"){echo("checked");}echo("> ja <input type=\"radio\" value=\"nee\" name=\"fax_laser\""); if("$fax_laser" == "nee"){echo("checked");}echo("> nee </td> </tr> <tr> <td colspan=\"2\"><br><strong>Functionaliteiten</strong></td> </tr> <tr> <td>Printer:</td> <td> <input type=\"radio\" value=\"ja\" name=\"fax_printer\""); if ("$fax_printer" == "ja"){echo ("checked");}echo("> ja <input type=\"radio\" value=\"nee\" name=\"fax_printer\""); if ("$fax_printer" == "nee"){echo ("checked");}echo("> nee </td> </tr> <tr> <td>Fax:</td> <td> <input type=\"radio\" value=\"ja\" name=\"fax_fax\""); if ("$fax_fax" == "ja"){echo ("checked");}echo("> ja <input type=\"radio\" value=\"nee\" name=\"fax_fax\""); if ("$fax_fax" == "nee"){echo ("checked");}echo("> nee </td> </tr> <tr> <td>Scanner:</td> <td> <input type=\"radio\" value=\"ja\" name=\"fax_scanner\""); if ("$fax_scanner" == "ja"){echo ("checked");}echo("> ja <input type=\"radio\" value=\"nee\" name=\"fax_scanner\""); if ("$fax_scanner" == "nee"){echo ("checked");}echo("> nee </td> </tr> <tr> <td>Copier:</td> <td> <input type=\"radio\" value=\"ja\" name=\"fax_copier\""); if ("$fax_copier" == "ja"){echo ("checked");}echo("> ja <input type=\"radio\" value=\"nee\" name=\"fax_copier\""); if ("$fax_copier" == "nee"){echo ("checked");}echo("> nee </td> </tr> <tr> <td>PC-Fax:</td> <td> <input type=\"radio\" value=\"ja\" name=\"fax_pcfax\""); if ("$fax_pcfax" == "ja"){echo ("checked");}echo("> ja <input type=\"radio\" value=\"nee\" name=\"fax_pcfax\""); if ("$fax_pcfax" == "nee"){echo ("checked");}echo("> nee </td> </tr> <tr> <td>Photo Capture Center:</td> <td> <input type=\"radio\" value=\"ja\" name=\"fax_pcc\""); if ("$fax_pcc" == "ja"){echo ("checked");}echo("> ja <input type=\"radio\" value=\"nee\" name=\"fax_pcc\""); if ("$fax_pcc" == "nee"){echo ("checked");}echo("> nee </td> </tr> <tr> <td>Message Center:</td> <td> <input type=\"radio\" value=\"ja\" name=\"fax_mc\""); if ("$fax_mc" == "ja"){echo ("checked");}echo("> ja <input type=\"radio\" value=\"nee\" name=\"fax_mc\""); if ("$fax_mc" == "nee"){echo ("checked");}echo("> nee </td> </tr> <tr> <td valign=\"top\"> Extra info: </td> <td> <textarea name=\"fax_extra\">$fax_extra</textarea> </td> </tr> <tr> <td> </td> <td> <input type=\"reset\" value=\"Leeg velden\"> <input type=\"submit\" value=\"Toevoegen\"> </td> </tr> </form>"); if ($submit){ if ($name) { ## Controleren of de waarde al voor komt binnen de site if($fax_type && mysql_result(mysql_query("SELECT COUNT(fax_type) FROM fax_apps WHERE fax_type LIKE '$fax_type'"),0)) { echo ("Het toestel dat u wilt toevoegen komt al voor in de database<br>Klik <a href=\"edit_phone.php?actie=menu&merk=$fax_brand\" class=\"tabellnk\">hier</a> om de lijst weer te geven.");} ## De hoogste grouporder uit de db halen en verhogen met 10 else {$result=mysql_query("SELECT MAX(fax_order) AS max_order FROM fax_apps WHERE fax_brand = '$fax_brand'")or die (mysql_error()); $row=mysql_fetch_object($result); $max_ord = intval($row->max_order); $next_order = $max_ord + 10; ## De hoogste id uit de db halen en verhogen met 1 $result=mysql_query("SELECT MAX(fax_id) AS max_id FROM fax_apps")or die (mysql_error()); $row=mysql_fetch_object($result); $max_idd = intval($row->max_id); $next_id = $max_idd + 1; ## Toevoegen in de database mysql_query("INSERT INTO fax_apps (fax_state, fax_name, fax_brand, fax_type, fax_paper, fax_cassette, fax_afdruksnelheid, fax_memory, fax_modem, fax_kleur, fax_laser, fax_printer, fax_fax, fax_scanner, fax_copier, fax_pcfax, fax_pcc, fax_mc, fax_extra )VALUES( '$fax_state', '$fax_name', '$fax_brand', '$fax_type', '$fax_paper', '$fax_cassette', '$fax_memory', '$fax_modem', '$fax_kleur', '$fax_laser', '$fax_printer', '$fax_fax', '$fax_scanner', '$fax_copier', '$fax_pcfax', '$fax_pcc', '$fax_mc', '$fax_extra')") or die (mysql_error()); $DeCode = strtoupper(md5(uniqid(time()))); $Hoofd = "From: www.domain.nl<mailer@domain.nl> MIME-Version: 1.0\r\nContent-type:multipart/mixed; boundary=$DeCode\r\nThis is a MIME encoded message. --$DeCode\r\nContent-type:text/plain\r\nContent-Transfer-Encoding:base64\r\n\r\n ".chunk_split(base64_encode("IP adres: $REMOTE_ADDR\r\nUser Agent: $HTTP_USER_AGENT\r\n$Contacthetmailtje\r\nDit bericht wordt automatische gegenereed en hier kan geen reply op gegeven worden. $name heeft de $fax_brand $fax_type toegevoegd. "))." --$DeCode\r\nContent-Type: $Bijlage_type; name = \"$Bijlage_name\"\r\nContent-Transfer-Encoding:base64\r\n ".chunk_split(base64_encode(fread(fopen($Bijlage, "r"), filesize($Bijlage))))."\r\n--$DeCode--"; mail("name@domain.nl","De $fax_brand $fax_type is door $name toegevoegd"," ","$Hoofd\r\nContent-type: text/html"); echo ("Het toestel $fax_brand $fax_type is toegevoegd!<br> Klik <a href=\"kaart.php?id=$next_id\">hier</a> om een kaartje te maken");} }else { echo ("Niet alle velden zijn ingevuld"); }} echo("<form action=\"kaart.php?id=\" enctype=\"multipart/form-data\"><select name=\"id\"><option>Maak uw keuze</option>"); $result=mysql_query("SELECT * FROM fax_apps ORDER BY fax_brand AND fax_type" ) or die (mysql_error()); while ($row=mysql_fetch_object($result)){ echo("<option value=\"$row->fax_id\">$row->fax_brand $row->fax_type</option>");} echo("</select> <input type=\"submit\" value=\"Afdrukken\" </form>"); ?> </body> </html> |
Nu heb ik deze code vanuit een ander script van mij overgenomen, die overigens wel werkt. Hierbij heb ik alleen de namen van scripts verander en het form.
Als ik dit script wil verwerken dan krijg ik
code:
Zelf denk ik dat ik ergens quote's te veel of te weinig gebruik. Kan iemand mij op weg helpen.
1
| Column count doesn't match value count at row 1 |