I have this database add page, which allows you to add more objects to a database and it works fine, but I need the entries to have an image attached to them and cant get it to work. Below is my current working solution (- the image), what do I need to add to make it able to have images uploaded to the entries. The variables are in finnish because that is the language I need to have the final product in so never mind them.
Here are pictures of the layout
The add page: https://i.stack.imgur.com/ycqqL.jpg
The index page that shows everything in the database: https://i.stack.imgur.com/JDpmd.jpg
<?php
$mysqli = new mysqli(---); // I put in lines to protect my personal info
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
$Tyyppi = $_POST["tyyppi"];
$Malli = $_POST["malli"];
$Sarjanumero = $_POST["sarjanum"];
$Paikka = $_POST["paikka"];
$Kuvaus = $_POST["kuvaus"];
$Lainassa = $_POST["laina"];
$Lainaaja = $_POST["lainaaja"];
$Puhelin = $_POST["puhelin"];
$Sposti = $_POST["sposti"];
$Palautus = $_POST["palautus"];
if ($Lainassa==1){
if ($stmt = $mysqli->prepare("INSERT laitteet (tyyppi, malli, sarjanumero, paikka, kuvaus, lainassa, lainaaja, puhelin, sposti, palautus) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"))
{
$stmt->bind_param("sssssissss", $Tyyppi, $Malli, $Sarjanumero, $Paikka, $Kuvaus, $Lainassa, $Lainaaja, $Puhelin, $Sposti, $Palautus);
$stmt->execute();
$stmt->close();
}
else
{
echo "ERROR: Could not prepare SQL statement.";
}
}else{
if ($stmt = $mysqli->prepare("INSERT laitteet (tyyppi, malli, sarjanumero, paikka, kuvaus, lainassa) VALUES (?, ?, ?, ?, ?, ?)"))
{
$stmt->bind_param("sssssi", $Tyyppi, $Malli, $Sarjanumero, $Paikka, $Kuvaus, $Lainassa);
$stmt->execute();
$stmt->close();
}
else
{
echo "ERROR: Could not prepare SQL statement.";
}
}
mysqli_close($mysqli);
?>