I'm trying to handle a form that updates some data in a postgreSQL table. To do that, I GET the id for the item to update. The URL reads:
[...]pojazd.php?id=1[...], which successfully GETs the data.
Then I want to store it in a session (that was opened before):
$_SESSION['id'] = $_GET['id'];
$id = $_SESSION['id'];
When I use my $id variable to SELECT the data, it works fine.
SELECT model, cena FROM pojazd WHERE id_poj = $id" does the job.
But when I want to update this data using a POST form:
if (isset($_POST['update'])){
[...]
UPDATE pojazd SET model = '$model', cena = '$cena' WHERE id_poj = $id;
}
nothing happens. When the $id variable is hardcoded (for example: replaced by 1 etc), it works fine. But the $id variable seems to unset itself whenever the form is POSTed. I tried echo'ing the $id variable whilst disabling the redirecting, and that's exactly what happens - the $id variable disappears.
I'm at a loss. The clock is ticking, I really don't want to fail my class, but that problems ruins my entire project...