Image update
ik ben bezig om wat afbeeldingen op te slaan in een database en dat is tot nu toe gelukt.
ik ben nu aan het proberen deze afbeeldingen aan een lid in de database te koppelen, maar dat lukt nog niet echt.
mijn tabel medewerkers heeft een blob veld en een afbeelding_naam veld, verder velden voor algemenen gegevens en een auto_increment ID veld.
hier mijn code:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Profielfoto</title>
</head>
<body>
<form action="uploaden.php" method="POST" enctype="multipart/form-data">
<input type="file" name="image">
<input type="submit" name="submit" value="Upload">
</form>
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
if(isset($_POST['submit']))
{
mysql_connect("localhost","5H_groep_Silvian","*****");
mysql_select_db("5H_groep_Silvian_5");
$ID="1"; //hier moet session
$fotoNaam = mysql_real_escape_string($_FILES["image"]["name"]);
$fotoData = mysql_real_escape_string(file_get_contents($_FILES["image"]["tmp_name"]));
$fotoType = mysql_real_escape_string($_FILES["image"]["type"]);
if(substr($fotoType,0,5) == "image")
{
mysql_query("Update `5H_groep_Silvian`.`Medewerkers` SET Afbeelding=$fotodata, Afbeelding_naam=$fotoNaam WHERE ID=$ID");
echo "Gefeliciteerd!<br>De afbeelding is geupload.";
}
else
{
echo "Alleen afbeeldingen!";
}
}
?>
if(isset($_POST['submit']))
{
mysql_connect("localhost","5H_groep_Silvian","*****");
mysql_select_db("5H_groep_Silvian_5");
$ID="1"; //hier moet session
$fotoNaam = mysql_real_escape_string($_FILES["image"]["name"]);
$fotoData = mysql_real_escape_string(file_get_contents($_FILES["image"]["tmp_name"]));
$fotoType = mysql_real_escape_string($_FILES["image"]["type"]);
if(substr($fotoType,0,5) == "image")
{
mysql_query("Update `5H_groep_Silvian`.`Medewerkers` SET Afbeelding=$fotodata, Afbeelding_naam=$fotoNaam WHERE ID=$ID");
echo "Gefeliciteerd!<br>De afbeelding is geupload.";
}
else
{
echo "Alleen afbeeldingen!";
}
}
?>
</body>
</html>
verder ben ik bezig met een zogenaamde smoelenboek,
ik moet dan proberen het opgeslagen plaatje in de database op het scherm te krijgen in de volgende code:
<html>
<head>
<link rel="stylesheet" type="text/css" href="SB.css" />
</head>
<body>
<div id="container">
<div id="titel"><H1 align="middle"> Smoelenboek </H1></div>
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
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
<?php
$inlognaam="5H_groep_Silvian";
$ww="Qwerty123";
$db="5H_groep_Silvian_5";
$host="LocalHost";
$query="SELECT * FROM Medewerkers";
mysql_connect("$host","$inlognaam","$ww");
Mysql_select_db("$db");
$result=mysql_query("$query");
while($row = mysql_fetch_array($result))
{
echo"
<div id='innercontent'>
<table id='table1'>
<tr>
<td id='naam' colspan='3'><h2 align='middle'> $row[Voornaam] $row[Tussenvoegsel] $row[Achternaam]</h2></td>
</tr>
<tr>
<td><strong> Geboortedatum </strong></td> <td> $row[Geboortedatum]</td>
<td rowspan='6' id='img'> <p align='middle'>
<img src='https://pbs.twimg.com/profile_images/1769323433/image.jpg' width='50px' height='50px'></p></td>
</tr>
<tr>
<td><strong> Geslacht </strong></td> <td> $row[Geslacht]</td>
</tr>
<tr>
<td><strong> Email </strong></td> <td> $row[Email]</td>
</tr>
<tr>
<td><strong> Telefoonnummer </strong></td> <td> $row[Telefoonnummer] </td>
</tr>
<tr>
<td><strong> functie </strong></td> <td> $row[Functie] </td>
</tr>
<tr>
<td><strong> status</strong></td> <td> $row[Status] </td>
</tr>
</table></div>";
}
?>
$inlognaam="5H_groep_Silvian";
$ww="Qwerty123";
$db="5H_groep_Silvian_5";
$host="LocalHost";
$query="SELECT * FROM Medewerkers";
mysql_connect("$host","$inlognaam","$ww");
Mysql_select_db("$db");
$result=mysql_query("$query");
while($row = mysql_fetch_array($result))
{
echo"
<div id='innercontent'>
<table id='table1'>
<tr>
<td id='naam' colspan='3'><h2 align='middle'> $row[Voornaam] $row[Tussenvoegsel] $row[Achternaam]</h2></td>
</tr>
<tr>
<td><strong> Geboortedatum </strong></td> <td> $row[Geboortedatum]</td>
<td rowspan='6' id='img'> <p align='middle'>
<img src='https://pbs.twimg.com/profile_images/1769323433/image.jpg' width='50px' height='50px'></p></td>
</tr>
<tr>
<td><strong> Geslacht </strong></td> <td> $row[Geslacht]</td>
</tr>
<tr>
<td><strong> Email </strong></td> <td> $row[Email]</td>
</tr>
<tr>
<td><strong> Telefoonnummer </strong></td> <td> $row[Telefoonnummer] </td>
</tr>
<tr>
<td><strong> functie </strong></td> <td> $row[Functie] </td>
</tr>
<tr>
<td><strong> status</strong></td> <td> $row[Status] </td>
</tr>
</table></div>";
}
?>
</div><!-- container -->
</body>
</html>
ik weet echter niet precies hoe ik dit aan moet pakken
alvast bedankt
groet,
Cas