dubbele record invoer??
Voer ik weer een nieuw record in dan word de nieuwe bestandnaam in het nieuwe record gezet, maar ook weer in het eerste record verandert.
Hoe kan dit?
vb
record1 bestand1
record2
record3
record4
record5 bestand1
maar na nieuwe invoer:
record1 bestand2
record2
record3
record4
record5 bestand1
record6 bestand2
Iets meer duidelijkheid? MySQL? Code?
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
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
<?PHP
<form action="invoerenevent.php" method="POST" enctype="multipart/form-data">
<table width="38%">
<tr>
<td width="53%" height="10">
<div align="left"><img src="images/Datumevent.jpg"
align="absbottom"><font face="Verdana"><font color="#FFFF00"><img
src="images/Sterretje.jpg" width="15" height="16"
align="absbottom"></font></font></div>
</td>
<td width="47%" height="10"><font face="Verdana">
<input type="text" name="datum" size="10" maxlength="10">
<img src="images/YYYY.jpg" width="126" height="19"></font></td>
</tr>
<tr>
<td width="53%" height="17">
<div align="left"><img src="images/Naamevent.jpg"
align="absbottom"><font face="Verdana"><font color="#FFFF00"><img
src="images/Sterretje.jpg" width="15" height="16"
align="absbottom"></font></font></div>
</td>
<td width="47%" height="17">
<p><font face="Verdana">
<input type="text" name="event_naam" size="28">
</font></p>
</td>
</tr>
<tr>
<td width="53%" height="3">
<div align="left"><font face="Verdana"><img src="images/Info1.jpg"
align="absbottom"></font></div>
</td>
<td width="47%" height="41" rowspan="2"><font face="Verdana">
<textarea name="info" cols="40" wrap="VIRTUAL"></textarea>
</font></td>
</tr>
<tr>
<td> </td>
[code]<?php
if(isset($_POST['submit']))
{
if (isset($_FILES['image1']['name']) && ($_FILES['image1']['name']) !== '')
{ $orgnaam="image1";
// UPLOAD GEDEELTE
error_reporting(E_ALL);
$path = "upload/Events/"; // folder waarin de plaatjes komen
$max_w = 640; // maximale breedte plaatje
$name = "Picture_"; // naam van het plaatje (eerst bestand wordt pict0.jpg, pict1.jpg, etc...)
$kwaliteit = "85"; // kwaliteit waarmee de JPG bewaard wordt
$maxsize = (80*1024); //1024(1 kb) * 300 = 300 kb
/////////////
include('config.php');
if($_SERVER['REQUEST_METHOD']=='POST'){
// if (isset($_FILES["image"]["name"]) && ($_FILES["image"]["name"]) !== "none"){
$file = $_FILES[$orgnaam]["name"]; // filename
$image = $_FILES[$orgnaam]["tmp_name"]; // tmp name
$type = $_FILES[$orgnaam]["type"]; // .ext
$size = $_FILES[$orgnaam]["size"]; //bestands grootte in bytes
if($size < $maxsize){
//afmetingen
$imageXY = getimagesize($image);
$img_w = $imageXY[0]; //width
$img_h = $imageXY[1]; //height
//resize plaatje
if($img_w > $max_w){
$factor = ($img_w / $max_w);
$newimg_w = $max_w;
$newimg_h = ($img_h / $factor);
}
$newImg_w = (isset($newimg_w)) ? $newimg_w : $img_w;
$newImg_h = (isset($newimg_h)) ? $newimg_h : $img_h;
//
if($imageXY[2]==2 || $imageXY[2]==3 || $imageXY[2]==6){
//switch bestandstype
$newImg = imagecreatetruecolor($newImg_w, $newImg_h);
$imgSrc = ImageCreateFromJPEG($image); //?
$imgSrcXY = getimagesize($image);
$imgSrc_w = $imgSrcXY[0];
$imgSrc_h = $imgSrcXY[1];
$i = 0;
while (file_exists($path.$name.$i.".jpg")) {
$i = $i + 1;
}
$name = $name.$i.".jpg";
//copy + verwijder tmp img
imagecopyresampled($newImg, $imgSrc, 0, 0, 0, 0, $newImg_w, $newImg_h, $imgSrc_w, $imgSrc_h);
imagejpeg($newImg, $path.$name);
imagedestroy($newImg);
// BESTANDSNAAM LINKEN
$idSQL = "SELECT event_id FROM event ORDER BY event_id";
$idQuery = mysql_query( $idSQL );
$idArray = mysql_fetch_assoc( $idQuery );
$id = $idArray['event_id'];
$sql = "UPDATE event SET upload='".$path.$name."' WHERE event_id=".$id;
mysql_query( $sql );
}//ext check
else{
$errors[]= "ongeldig bestandstype!";
}
}//if maxsize
else{
$errors[] = "Bestand is te groot, maximaal ".($maxsize/1024);
}
// }//!= none
} //post
echo '<SCRIPT>';
echo 'window.location.href = "Events.php"';
echo '</SCRIPT>';
}
else {}
}
else {
?>
</tr>
<tr>
<td height="18"><img src="images/Advertentie.jpg"></td>
<td height="18">
<input type="file" name="image1" size="36">
</td>
</tr>
<?PHP
}
?>
<tr>
<td width="53%" height="7"><font face="Verdana"> <img
src="images/Organisator.jpg" align="absbottom"><font color="#FFFF00"><img
src="images/Sterretje.jpg" width="15" height="16"
align="absbottom"></font></font></td>
<td width="47%" height="7"><font face="Verdana">
<input type="text" name="georganiseerd" size="28">
</font></td>
</tr>
<tr>
<td width="53%" height="8"><img src="images/Telefoon.jpg" width="94"
height="20"><font face="Verdana"><font color="#FFFF00"><img
src="images/Sterretje.jpg" width="15" height="16"
align="absbottom"></font></font></td>
<td width="47%" height="8"><font face="Verdana">
<input type="text" name="telefoon" size="15" maxlength="15">
</font></td>
</tr>
<tr>
<td width="53%" height="8"><img src="images/Mobiele-telefoon.jpg"
width="169" height="20"><font face="Verdana"></font></td>
<td width="47%" height="8"><font face="Verdana">
<input type="text" name="mobiel" size="15" maxlength="15">
</font></td>
</tr>
<tr>
<td width="53%" height="17"><font face="Verdana"><img
src="images/Email-adres.jpg" align="absbottom"><font face="Verdana"><font
color="#FFFF00"><img src="images/Sterretje.jpg" width="15" height="16"
align="absbottom"></font></font><font color="#FFFF00"></font></font></td>
<td width="47%" height="17"><font face="Verdana">
<input type="text" name="email" maxlength="35" size="35">
</font></td>
</tr>
</table>
<br>
<font face="Verdana"><img src="images/Alle-velden.jpg" width="366"
height="19"></font><br><br>
<input type="hidden" name="submit" value="hiddenValue" border="0">
<input type=submit name=submit value="REGISTER">
<br>
</form>
</font>
</center>
<div align="center"><a href="Events.php" onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Image19','','Buttons/Back-rollover.jpg',1)"><img
name="Image19" border="0" src="Buttons/Back.jpg"></a></div>
</html>
<?PHP
if($_POST['submit']){
$datum = $_POST['datum'];
$event_naam = $_POST['event_naam'];
$info = $_POST['info'];
$georganiseerd = $_POST['georganiseerd'];
$email = $_POST['email'];
$telefoon = $_POST['telefoon'];
$mobiel = $_POST['mobiel'];
$ip = getenv("REMOTE_ADDR");
include ('config.php');
$sql = "INSERT INTO event(datum, event_naam, info, georganiseerd, IPnummer,
email, telefoon, mobiel, upload) VALUES ('$datum', '$event_naam', '$info',
'$georganiseerd', '$ip', '$email', '$telefoon', '$mobiel', '$path$name')";
mysql_query($sql);
}
?>
<form action="invoerenevent.php" method="POST" enctype="multipart/form-data">
<table width="38%">
<tr>
<td width="53%" height="10">
<div align="left"><img src="images/Datumevent.jpg"
align="absbottom"><font face="Verdana"><font color="#FFFF00"><img
src="images/Sterretje.jpg" width="15" height="16"
align="absbottom"></font></font></div>
</td>
<td width="47%" height="10"><font face="Verdana">
<input type="text" name="datum" size="10" maxlength="10">
<img src="images/YYYY.jpg" width="126" height="19"></font></td>
</tr>
<tr>
<td width="53%" height="17">
<div align="left"><img src="images/Naamevent.jpg"
align="absbottom"><font face="Verdana"><font color="#FFFF00"><img
src="images/Sterretje.jpg" width="15" height="16"
align="absbottom"></font></font></div>
</td>
<td width="47%" height="17">
<p><font face="Verdana">
<input type="text" name="event_naam" size="28">
</font></p>
</td>
</tr>
<tr>
<td width="53%" height="3">
<div align="left"><font face="Verdana"><img src="images/Info1.jpg"
align="absbottom"></font></div>
</td>
<td width="47%" height="41" rowspan="2"><font face="Verdana">
<textarea name="info" cols="40" wrap="VIRTUAL"></textarea>
</font></td>
</tr>
<tr>
<td> </td>
[code]<?php
if(isset($_POST['submit']))
{
if (isset($_FILES['image1']['name']) && ($_FILES['image1']['name']) !== '')
{ $orgnaam="image1";
// UPLOAD GEDEELTE
error_reporting(E_ALL);
$path = "upload/Events/"; // folder waarin de plaatjes komen
$max_w = 640; // maximale breedte plaatje
$name = "Picture_"; // naam van het plaatje (eerst bestand wordt pict0.jpg, pict1.jpg, etc...)
$kwaliteit = "85"; // kwaliteit waarmee de JPG bewaard wordt
$maxsize = (80*1024); //1024(1 kb) * 300 = 300 kb
/////////////
include('config.php');
if($_SERVER['REQUEST_METHOD']=='POST'){
// if (isset($_FILES["image"]["name"]) && ($_FILES["image"]["name"]) !== "none"){
$file = $_FILES[$orgnaam]["name"]; // filename
$image = $_FILES[$orgnaam]["tmp_name"]; // tmp name
$type = $_FILES[$orgnaam]["type"]; // .ext
$size = $_FILES[$orgnaam]["size"]; //bestands grootte in bytes
if($size < $maxsize){
//afmetingen
$imageXY = getimagesize($image);
$img_w = $imageXY[0]; //width
$img_h = $imageXY[1]; //height
//resize plaatje
if($img_w > $max_w){
$factor = ($img_w / $max_w);
$newimg_w = $max_w;
$newimg_h = ($img_h / $factor);
}
$newImg_w = (isset($newimg_w)) ? $newimg_w : $img_w;
$newImg_h = (isset($newimg_h)) ? $newimg_h : $img_h;
//
if($imageXY[2]==2 || $imageXY[2]==3 || $imageXY[2]==6){
//switch bestandstype
$newImg = imagecreatetruecolor($newImg_w, $newImg_h);
$imgSrc = ImageCreateFromJPEG($image); //?
$imgSrcXY = getimagesize($image);
$imgSrc_w = $imgSrcXY[0];
$imgSrc_h = $imgSrcXY[1];
$i = 0;
while (file_exists($path.$name.$i.".jpg")) {
$i = $i + 1;
}
$name = $name.$i.".jpg";
//copy + verwijder tmp img
imagecopyresampled($newImg, $imgSrc, 0, 0, 0, 0, $newImg_w, $newImg_h, $imgSrc_w, $imgSrc_h);
imagejpeg($newImg, $path.$name);
imagedestroy($newImg);
// BESTANDSNAAM LINKEN
$idSQL = "SELECT event_id FROM event ORDER BY event_id";
$idQuery = mysql_query( $idSQL );
$idArray = mysql_fetch_assoc( $idQuery );
$id = $idArray['event_id'];
$sql = "UPDATE event SET upload='".$path.$name."' WHERE event_id=".$id;
mysql_query( $sql );
}//ext check
else{
$errors[]= "ongeldig bestandstype!";
}
}//if maxsize
else{
$errors[] = "Bestand is te groot, maximaal ".($maxsize/1024);
}
// }//!= none
} //post
echo '<SCRIPT>';
echo 'window.location.href = "Events.php"';
echo '</SCRIPT>';
}
else {}
}
else {
?>
</tr>
<tr>
<td height="18"><img src="images/Advertentie.jpg"></td>
<td height="18">
<input type="file" name="image1" size="36">
</td>
</tr>
<?PHP
}
?>
<tr>
<td width="53%" height="7"><font face="Verdana"> <img
src="images/Organisator.jpg" align="absbottom"><font color="#FFFF00"><img
src="images/Sterretje.jpg" width="15" height="16"
align="absbottom"></font></font></td>
<td width="47%" height="7"><font face="Verdana">
<input type="text" name="georganiseerd" size="28">
</font></td>
</tr>
<tr>
<td width="53%" height="8"><img src="images/Telefoon.jpg" width="94"
height="20"><font face="Verdana"><font color="#FFFF00"><img
src="images/Sterretje.jpg" width="15" height="16"
align="absbottom"></font></font></td>
<td width="47%" height="8"><font face="Verdana">
<input type="text" name="telefoon" size="15" maxlength="15">
</font></td>
</tr>
<tr>
<td width="53%" height="8"><img src="images/Mobiele-telefoon.jpg"
width="169" height="20"><font face="Verdana"></font></td>
<td width="47%" height="8"><font face="Verdana">
<input type="text" name="mobiel" size="15" maxlength="15">
</font></td>
</tr>
<tr>
<td width="53%" height="17"><font face="Verdana"><img
src="images/Email-adres.jpg" align="absbottom"><font face="Verdana"><font
color="#FFFF00"><img src="images/Sterretje.jpg" width="15" height="16"
align="absbottom"></font></font><font color="#FFFF00"></font></font></td>
<td width="47%" height="17"><font face="Verdana">
<input type="text" name="email" maxlength="35" size="35">
</font></td>
</tr>
</table>
<br>
<font face="Verdana"><img src="images/Alle-velden.jpg" width="366"
height="19"></font><br><br>
<input type="hidden" name="submit" value="hiddenValue" border="0">
<input type=submit name=submit value="REGISTER">
<br>
</form>
</font>
</center>
<div align="center"><a href="Events.php" onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Image19','','Buttons/Back-rollover.jpg',1)"><img
name="Image19" border="0" src="Buttons/Back.jpg"></a></div>
</html>
<?PHP
if($_POST['submit']){
$datum = $_POST['datum'];
$event_naam = $_POST['event_naam'];
$info = $_POST['info'];
$georganiseerd = $_POST['georganiseerd'];
$email = $_POST['email'];
$telefoon = $_POST['telefoon'];
$mobiel = $_POST['mobiel'];
$ip = getenv("REMOTE_ADDR");
include ('config.php');
$sql = "INSERT INTO event(datum, event_naam, info, georganiseerd, IPnummer,
email, telefoon, mobiel, upload) VALUES ('$datum', '$event_naam', '$info',
'$georganiseerd', '$ip', '$email', '$telefoon', '$mobiel', '$path$name')";
mysql_query($sql);
}
?>
maar verder gewoon een insert en een update naar elkaar
Ja dat klopt dus :-)
Thanx voor de tip.
nog een laatste vraag als ik een record (met link naar bestandje)verwijder is het dan mogelijk dat ie ook het bestandje zelf verwijdert
Gewijzigd op 02/04/2005 17:39:00 door Franko