Forum » Server-Side scripting » In database opslaan
NJMedia
Berichten: 1146
avatar
Offline Stuur privebericht
Beste CP'ers,

Ik ben bezig met een community script maar nu loop ik tegen een probleem aan wat ik echt niet zelf zie.

Dit script zou gegevens moeten opslaan in de database:

Code | Selecteer Alles
minimaliseren
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
<?

include("global.php");
include(
"header.php");

if(
ingelogd() == TRUE){

    if(isset(
$_GET['actie']) AND $_GET['actie'] == "controleren"){

        if(!empty(
$_POST['avatar'])){

        if(
remote_file_exists($_POST['avatar'])){

            list(
$width$height$type$attr) = getimagesize($_POST['avatar']);

            if(
$width 100 OR $height 100){

            
begintabel("Foutmelding");

            echo 
"De door u gekozen avatar voldoet niet aan onze eisen: maximaal 100x100!<br>
            Uw avatar is "
.$width."x".$height."!";

            
eindetabel();

            } else {

        @
mysql_query("UPDATE leden SET
        
        woonplaats='"
.addslashes($_POST['woonplaats'])."',
        homepage='"
.addslashes($_POST['homepage'])."',
        land='"
.addslashes($_POST['land'])."',
        designen='"
.addslashes($_POST['designen'])."',
        php='"
.addslashes($_POST['php'])."',
        signature='"
.addslashes($_POST['signature'])."',
        jquery='"
.addslashes($_POST['jquery'])."',
        htmlcss='"
.addslashes($_POST['htmlcss'])."',
        SEO='"
.addslashes($_POST['SEO'])."',

        avatar='"
.$_POST['avatar']."'

        WHERE id='"
.$_COOKIE['id']."'") or die(mysql_error());

        
begintabel("Profiel bijgewerkt");

        echo 
"Uw profiel is succesvol bijgewerkt!";

        
eindetabel();

            }

        } else {

        
begintabel("Foutmelding");

        echo 
"De door u gekozen avatar bestaat niet!";

        
eindetabel();

        }

        } else {

        @
mysql_query("UPDATE leden SET
        
        
        woonplaats='"
.addslashes($_POST['woonplaats'])."',
        homepage='"
.addslashes($_POST['homepage'])."',
        land='"
.addslashes($_POST['land'])."',
        designen='"
.addslashes($_POST['designen'])."',
        php='"
.addslashes($_POST['php'])."',
        signature='"
.addslashes($_POST['signature'])."',
        jquery='"
.addslashes($_POST['jquery'])."',
        htmlcss='"
.addslashes($_POST['htmlcss'])."',
        SEO='"
.addslashes($_POST['SEO'])."',
        avatar='"
.$_POST['avatar']."'


        WHERE id='"
.$_COOKIE['id']."'") or die(mysql_error());

        
begintabel("Profiel bijgewerkt");

        echo 
"Uw profiel is succesvol bijgewerkt!";

        
eindetabel();

        }

    } else {

        echo 
"<form name='pw' action='".$_SERVER['PHP_SELF']."?actie=controleren' method='POST'>";

        
begintabel("Persoonlijke gegevens");

        
$query = @mysql_query("SELECT * FROM leden WHERE id='".$_COOKIE['id']."'");
        
$row = @mysql_fetch_assoc($query);

        echo 
"<table width='100%' border='0' cellpadding='0' cellspacing='0'>
        
        <tr>
            <td width='50%' height='24'>Woonplaats</td>
            <td width='50%' height='24'><input type='text' name='woonplaats' value='"
.stripslashes($row['woonplaats'])."'></td>
        </tr>
        <tr>
            <td width='50%' height='24'>Land</td>
            <td width='50%' height='24'>"
;
        
        if(
$row['land'] == "Nederland"){

            echo 
"<select size='1' name='land'>
            <option value='Nederland' selected>Nederland</option>
            <option value='België'>Beglië</option>
            <option value='Overig'>Overig</option>
            </select>"
;
            
        } elseif(
$row['land'] == "Beglië"){

            echo 
"<select size='1' name='land'>
            <option value='Nederland'>Nederland</option>
            <option value='België' selected>Beglië</option>
            <option value='Overig'>Overig</option>
            </select>"
;
            
        } else {

            echo 
"<select size='1' name='land'>
            <option value='Nederland'>Nederland</option>
            <option value='België'>Beglië</option>
            <option value='Overig' selected>Overig</option>
            </select>"
;
            
        }
        
        echo 
"</td>
        </tr>
        <tr>
            <td width='50%' height='24'>Website(s)</td>
            <td width='50%' height='24'><input type='text' name='homepage' value='"
.stripslashes($row['homepage'])."'></td>
        </tr>
        </table>"
;

        
eindetabel();

        echo 
"<br>";

        
begintabel("Signature");

        echo 
icon("pw""signature");

        echo 
"<textarea style='width: 100%;' name='signature' rows='6'>".htmlspecialchars(stripslashes($row['signature']))."</textarea>";

        
eindetabel();

        echo 
"<br>";

        
begintabel("Avatar");

        echo 
"<table width='100%' border='0' cellpadding='0' cellspacing='0'>
        <tr>
            <td width='50%' height='24'>Huidige avatar<br>&nbsp;</td>
            <td width='50%' height='24' valign='top'>"
;
        
        if(!empty(
$row['avatar'])){
            
            echo 
"<img src='".$row['avatar']."'>";
            
        } else {
            
            echo 
"<i>Geen avatar ingesteld</i>";

        }
            
        echo 
"<br>&nbsp;</td>
        </tr>
        <tr>
            <td width='50%' height='24'>Avatar URL</td>
            <td width='50%' height='24'><input type='text' name='avatar' value='"
.stripslashes($row['avatar'])."'></td>
        </tr>
        </table>"
;

        
eindetabel();

        echo 
"<br>";

        
begintabel("Vaardigheden");

        
$designen[1] = "";
        
$designen[2] = "";
        
$designen[3] = "";
        
$designen[4] = "";
        
$designen[5] = "";
        
$designen[$row['designen']] = " selected";

        
$php[1] = "";
        
$php[2] = "";
        
$php[3] = "";
        
$php[4] = "";
        
$php[5] = "";
        
$php[$row['php']] = " selected";

        
$htmlcss[1] = "";
        
$htmlcss[2] = "";
        
$htmlcss[3] = "";
        
$htmlcss[4] = "";
        
$htmlcss[5] = "";
        
$htmlcss[$row['htmlcss']] = " selected";

        
$jquery[1] = "";
        
$jquery[2] = "";
        
$jquery[3] = "";
        
$jquery[4] = "";
        
$jquery[5] = "";
        
$jquery[$row['jquery']] = " selected";

        
$SEO[1] = "";
        
$SEO[2] = "";
        
$SEO[3] = "";
        
$SEO[4] = "";
        
$SEO[5] = "";
        
$SEO[$row['SEO']] = " selected";

        echo 
"<table width='100%' border='0' cellpadding='0' cellspacing='0'>
        <tr>
            <td width='50%' height='24'>Webdesign</td>
            <td width='50%' height='24'><select size='1' name='designen'>
            <option value='1'"
.$designen[1].">1</option>
            <option value='2'"
.$designen[2].">2</option>
            <option value='3'"
.$designen[3].">3</option>
            <option value='4'"
.$designen[4].">4</option>
            <option value='5'"
.$designen[5].">5</option>
            </select></td>
        </tr>
        <tr>
            <td width='50%' height='24'>Programmeren</td>
            <td width='50%' height='24'><select size='1' name='php'>
            <option value='1'"
.$php[1].">1</option>
            <option value='2'"
.$php[2].">2</option>
            <option value='3'"
.$php[3].">3</option>
            <option value='4'"
.$php[4].">4</option>
            <option value='5'"
.$php[5].">5</option>
            </select></td>
        </tr>
        <tr>
            <td width='50%' height='24'>(X)HTML/CSS</td>
            <td width='50%' height='24'><select size='1' name='htmlcss'>
            <option value='1'"
.$htmlcss[1].">1</option>
            <option value='2'"
.$htmlcss[2].">2</option>
            <option value='3'"
.$htmlcss[3].">3</option>
            <option value='4'"
.$htmlcss[4].">4</option>
            <option value='5'"
.$htmlcss[5].">5</option>
            </select></td>
        </tr>
        <tr>
            <td width='50%' height='24'>jQuery</td>
            <td width='50%' height='24'><select size='1' name='jquery'>
            <option value='1'"
.$jquery[1].">1</option>
            <option value='2'"
.$jquery[2].">2</option>
            <option value='3'"
.$jquery[3].">3</option>
            <option value='4'"
.$jquery[4].">4</option>
            <option value='5'"
.$jquery[5].">5</option>
            </select></td>
        </tr>
        <tr>
            <td width='50%' height='24'>SEO</td>
            <td width='50%' height='24'><select size='1' name='SEO'>
            <option value='1'"
.$SEO[1].">1</option>
            <option value='2'"
.$SEO[2].">2</option>
            <option value='3'"
.$SEO[3].">3</option>
            <option value='4'"
.$SEO[4].">4</option>
            <option value='5'"
.$SEO[5].">5</option>
            </select></td>
        </tr>        
        </table>"
;

        
eindetabel();
        
        echo 
"<br>";

        echo 
"<br>";

        
begintabel("Bevestigen");

        echo 
"<input type='submit' value='Profiel Wijzigen'>";

        
eindetabel();

        echo 
"</form>";

    }

} else {

    
begintabel("Foutmelding");

    echo 
"U dient ingelogd te zijn om deze pagina te kunnen bekijken!";

    
eindetabel();

}

include(
"footer.php");

?>


Nou doet hij dit behalve met 'Vaardigheden' -> SEO, jQuery en (X)Html/CSS.

Iemand enig idee waar het probleem zit?

Met vriendelijke groet
Nils Henderik
12-12-2011 19:15
Dit topic is 276 keer bekeken door 30 verschillende leden
Reacties op: "In database opslaan"
1
NJMedia
Berichten: 1146
avatar
Offline Stuur privébericht
Het is al gelukt. Kan een slotje op

Ik was

Code | Selecteer Alles
minimaliseren
1
2
3
4
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{

}


Wel erg stom dat ik dat over het hoofd heb gezien
12-12-2011 22:32
Rapifia Europe
Berichten: 3719
avatar
Offline Stuur privébericht
op aanvraag van TS.
12-12-2011 22:47
Reageer op: "In database opslaan"
1
Je kan niet reageren omdat je niet bent ingelogd. Inloggen of Aanmelden