Hello, I have problem with pdo insert query that doesn’t make any sense to me! So I have this rating from 1-5, and should go on ocena.php file to get that id and store the result in the database. So this is the loop for links for 1 -5.:
<?php foreach (range(1, 5) as $ocena) { ?> <?php } ?>And it is working fine, here is the link when i click on let say number 3:
http://localhost/sistem-za-administraciju/clanak.php?id=21
So it redirects to ocena.php and here is the code:
<?php include_once 'includes/konekcija.php'; if (isset($_GET['clanak']) & isset( $_GET['ocena'])) { $clanak = $_GET['clanak']; $ocena = $_GET['ocena']; if (in_array($ocena, [1,2,3,4,5])) { $niz = $pdo->prepare("SELECT id FROM clanci WHERE id =:id"); $niz->bindParam(":id", $clanak); $niz->execute(); $red = $niz->fetch(); if ($red) { $upit = $pdo->prepare("INSERT INTO ocene (clanak, ocena) VALUES (?, ?)"); $upit->bindValue(1, $clanak); $upit->bindValue(2, $ocene); $upit->execute(); header('Location: clanak.php?id=' .$clanak); } else { echo 'Nesto nije u redu.'; } } } It is showing no errors, it redirects to page like it should, but the result is not stored/saved in my database. Anybody has an idea?