Hallo zusammen,
Ich bin am Entwickeln einer Internetseite, worauf man sich anmelden kann und sozusagen sein Profil erstellt und auch Bilder hochladen kann.
Hier liegt das Problem. Das Bild wird zwar mühelos hochgeladen und gespeichert, aber ein Datenbankeintrag wird nicht gemacht. Ich habe einige Dinge probiert (Code leicht modifiziert), im Internet recherchiert und auch einen Fortgeschrittenen User gefragt. Trotzdem konnte mir leider keiner helfen. So hoffe ich, dass ihr das könnt.
Das funktioniert so:
in der Datei einstellungen_bild_upload_album.php ist das Formular, in dem man das Bild wählen und andere Angaben dazu machen kann.
mittels form action wird mit der Datei einstellungen_bild_upload_album_aktion.php hochgeladen.
Hier ist der Code der Formulardatei einstellungen_bild_upload_album.php
PHP-Code:
<?php
// ***
// Bilder hochladen
// ***
include("database_connect.php");
include("head_login.php");
// Daten des Angemeldeten ermitteln
$ergebnis = mysql_query("SELECT * FROM mitglieder WHERE EMail = '$_SESSION[user]'");
while($row = mysql_fetch_object($ergebnis))
{
$ID = $row->ID;
$Vorname = $row->Vorname;
$Nachname = $row->Nachname;
$Heimatort = $row->Heimatort;
$Wohnort = $row->Wohnort;
$Kanton = $row->Kanton;
$EMail = $row->EMail;
$Geschlecht = $row->Geschlecht;
$Geburtsdatum = $row->Geburtsdatum;
$Anzeigebild = $row->Anzeigebild;
?>
<html>
<head>
<title>
Sono-Io
</title>
<style type="text/css">
a:link { color: black; text-decoration: none; }
a:visited { color: black; text-decoration: none; }
a:focus { color: black; text-decoration: none; background:none; }
a:hover { color: black; text-decoration: underline; background: none; }
a:active { color: black; text-decoration: none; background: none; }
body { font-family:Calibri, Segoe UI, Arial; }
</style>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
<table border="0" width="100%">
<tr>
<td width="1" height="1">
</td>
<td width="400" height="1">
</td>
<td height="1">
</td>
</tr>
<tr>
<td height="50">
</td>
<td colspan="2" valign="top">
<h2>Einstellungen</h2>
</td>
</tr>
<tr>
<td>
</td>
<td valign="top">
<a href="einstellungen_person.php">Persönliche Einstellungen</a><br>
<a href="einstellungen_bilder.php"><b><font color="#0000FF">Bilder</font></b></a><br>
<a href="einstellungen_passwort.php">Passwort ändern</a>
</td>
<td valign="top">
<h2>Ein Bild hochladen</h2>
<form action="einstellungen_bild_upload_album_aktion.php" method="post" enctype="multipart/form-data">
<table border="0">
<tr>
<td>
Datei:
</td>
<td>
<input type="file" name="file" size="50">
</td>
</tr>
<tr>
<td>
Titel:
</td>
<td>
<input type="text" name="bildtitel" size="50">
</td>
</tr>
<td>
Beschreibung:
</td>
<td>
<textarea name="bildbeschreibung" cols="50" rows="10"></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Hochladen">
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?php
}
?>
</body>
</html>
Und hier die Datei einstellungen_bild_upload_album_aktion.php:
PHP-Code:
<?php
// ***
// Bilder hochladen - machen
// ***
include("database_connect.php");
include("head_login.php");
// Daten des Angemeldeten ermitteln
$ergebnis = mysql_query("SELECT * FROM mitglieder WHERE EMail = '$_SESSION[user]'");
while($row = mysql_fetch_object($ergebnis))
{
$ID = $row->ID;
$Vorname = $row->Vorname;
$Nachname = $row->Nachname;
$Heimatort = $row->Heimatort;
$Wohnort = $row->Wohnort;
$Kanton = $row->Kanton;
$EMail = $row->EMail;
$Geschlecht = $row->Geschlecht;
$Geburtsdatum = $row->Geburtsdatum;
$Anzeigebild = $row->Anzeigebild;
?>
<html>
<head>
<title>
Sono-Io
</title>
<style type="text/css">
a:link { color: black; text-decoration: none; }
a:visited { color: black; text-decoration: none; }
a:focus { color: black; text-decoration: none; background:none; }
a:hover { color: black; text-decoration: underline; background: none; }
a:active { color: black; text-decoration: none; background: none; }
body { font-family:Calibri, Segoe UI, Arial; }
</style>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
<table border="0" width="100%">
<tr>
<td width="1" height="1">
</td>
<td width="400" height="1">
</td>
<td height="1">
</td>
</tr>
<tr>
<td height="50">
</td>
<td colspan="2" valign="top">
<h2>Einstellungen</h2>
</td>
</tr>
<tr>
<td>
</td>
<td valign="top">
<a href="einstellungen_person.php">Persönliche Einstellungen</a><br>
<a href="einstellungen_bilder.php"><b><font color="#0000FF">Bilder</font></b></a><br>
<a href="einstellungen_passwort.php">Passwort ändern</a>
</td>
<td valign="top">
<h2>Ein Bild hochladen</h2>
<?php
include("zeitstempel.php");
$user = $ID;
$tempname = $_FILES['file']['tmp_name'];
$underscore = "_";
$name = $_FILES['file']['name'];
$date2 = date("Y-m-d-H-i-s");
$dateityp = GetImageSize($_FILES['file']['tmp_name']);
if($dateityp[2] != 0)
{
if($_FILES['file']['size'] < 5242880)
{
move_uploaded_file($_FILES['file']['tmp_name'], "Bilder/".$date2.$underscore.$_FILES['file']['name']);
die("Das Bild wurde erfolgreich hochgeladen.");
}
else
{
die("Das Bild ist zu Gross.");
}
}
else
{
header("Es ist kein Bild vorhanden");
}
?>
<?php
// Eintrag in die Datenbanktabelle BILDER machen
$pfad = "Bilder/".$date2.$underscore.$_FILES['file']['name'];
$dbtitel = mysql_real_escape_string($_POST['bildtitel']);
$dbbeschreibung = mysql_real_escape_string($_POST['bildbeschreibung']);
$dbalbum = mysql_real_escape_string($_POST['album']);
mysql_query("INSERT INTO bilder (`Benutzer`,`Bildpfad`,`Bildtitel`,`Bildbeschreibung`,`Datum`,`Album`) VALUES ('$user','$pfad','$dbtitel','$dbbeschreibung,'$zeitstempel','$dbalbum')") or die(mysql_error());
?>
</td>
</tr>
</table>
<?php
}
?>
</body>
</html>
Wie bereits gesagt, das Bild wird einwandfrei und Fehlerlos hochgeladen. Nur der Eintrag in die Datenbank, das funktioniert nicht
Ich hoffe sehr, dass ich mir behilflich sein könnt und danke euch jetzt bereits im Voraus für eure Hilfe

.