EDIT: The problem now is there are no more code errors causing error/notice splats thanks to contributors, but the data still isn't being posted into the MYSQL db, the table is just empty even though script says it's been uploaded.
Here's the code:
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$ogrod_id = trim(sql_safe($_POST['ogrod_id']));
$doborsadzenieroslin = trim(sql_safe($_POST['doborsadzenieroslin']));
$nawierzchnia = trim(sql_safe($_POST['nawierzchnia']));
$systnawadn = trim(sql_safe($_POST['systnawadn']));
$malaarchitektura = trim(sql_safe($_POST['malaarchitektura']));
$oczkawodne = trim(sql_safe($_POST['oczkawodne']));
$trawniki = trim(sql_safe($_POST['trawniki']));
$oswietlenie = trim(sql_safe($_POST['oswietlenie']));
$tarasy = trim(sql_safe($_POST['tarasy']));
$pielegnacja = trim(sql_safe($_POST['pielegnacja']));
$opis = trim(sql_safe($_POST['opis']));
if ($opis === '') {
$opis = '(brak opisu)';
}
if ($password !== 'jeeus') {
$msg = 'Błąd - błędne hasło wgrywania.';
} else {
if (isset($_FILES['image'])) {
$image = $_FILES['image'];
@list(, , $imtype, ) = getimagesize($_FILES['image']['tmp_name']);
if ($imtype === 3)
$ext="png";
elseif ($imtype === 2)
$ext="jpeg";
elseif ($imtype === 1)
$ext="gif";
else
$msg = 'Błąd - nieznany format pliku.';
if (!isset($msg)) {
$data = file_get_contents($_FILES['image']['tmp_name']);
$data = mysqli_real_escape_string($con, $data);
mysqli_query($con, "INSERT INTO realizacje (ext,opis,image,ogrod_id,doborsadzenierosli,nawierzchnia,systnawadn,malaarchitektura,oczkawodne,trawniki,oswietlenie,tarasy,pielegnacja) VALUES ('$ext','$opis','$data','$ogrod_id','$doborsadzenieroslin','$nawierzchnia','$systnawadn','$malaarchitektura','$oczkawodne','$trawniki','$oswietlenie','$tarasy','$pielegnacja')");
$msg = 'Sukces - obraz został wgrany na serwer.';
}
} else if (isset($_GET['ogrod_id'])) {
$msg = 'Błąd - plik nie został wgrany.';
}
}
}
?>
Here's the HTML markup for image along with it's name property.
Also, the whole form HTML part:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">
<div id="filtry">
<div class="realizacjedodaj">
<b>Czy na zdjęciu znajduje/ą się <br>wykonany/e przez firmę:</b><br><br>
<label for="doborsadzenieroslin">dobór/sadzenie roślin?</label><br />
<input type="radio" name="doborsadzenieroslin" value="0" checked> Tak
<input type="radio" name="doborsadzenieroslin" value="1"> Nie<br><br>
<label for="nawierzchnia">nawierzchnia?</label><br />
<input type="radio" name="nawierzchnia" value="0" checked> Tak
<input type="radio" name="nawierzchnia" value="1"> Nie<br><br>
<label for="systnawadn">system nawadniający?</label><br />
<input type="radio" name="systnawadn" value="0" checked> Tak
<input type="radio" name="systnawadn" value="1"> Nie<br><br>
<label for="malaarchitektura">mała architektura?</label><br />
<input type="radio" name="malaarchitektura" value="0" checked> Tak
<input type="radio" name="malaarchitektura" value="1"> Nie<br><br>
</div>
<div class="realizacjedodaj">
<label for="oczkawodne">oczko wodne?</label><br />
<input type="radio" name="oczkawodne" value="0" checked> Tak
<input type="radio" name="oczkawodne" value="1"> Nie<br><br>
<label for="trawniki">trawnik?</label><br />
<input type="radio" name="trawniki" value="0" checked> Tak
<input type="radio" name="trawniki" value="1"> Nie<br><br>
<label for="oswietlenie">oswietlenie?</label><br />
<input type="radio" name="oswietlenie" value="0" checked> Tak
<input type="radio" name="oswietlenie" value="1"> Nie<br><br>
<label for="tarasy">taras?</label><br />
<input type="radio" name="tarasy" value="0" checked> Tak
<input type="radio" name="tarasy" value="1"> Nie<br><br>
<label for="pielegnacja">pielęgnacja ogrodu?</label><br />
<input type="radio" name="pielegnacja" value="0" checked> Tak
<input type="radio" name="pielegnacja" value="1"> Nie<br><br>
</div>
</div>
<div id="listaOgrodow">
<div class="realizacjedodaj">
<label for="ogrod_id"><b>Ogród:</b></label><br />
<?php
$ogrodysql = "SELECT id_ogrodu, nazwa FROM ogrody";
$result = mysqli_query($con, $ogrodysql);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
echo "#" . $row["id_ogrodu"]. " " . $row["nazwa"]. "<input type='radio' name='ogrod_id' value=" .$row["id_ogrodu"]." <br>";
}
} else {
echo "0 results";
}
?>
<br /><br /><br />
</div>
</div>
<div id="resztaDanych" class="realizacjedodaj">
<br><br>
<label for="image">Zdjęcie realizacji:</label><br />
<input type="file" name="image" id="image"/><br /><br /><br />
<label for="opis">Opis (opcjonalnie):</label><br />
<textarea rows="4" cols="50" name="opis" id="opis"></textarea><br /><br /><br />
<input type="submit" value="Wgraj"/>
</div>
</form>