I am trying to write a PHP file to update data in my database, but for some reason the if statements are not working. I have tested to see if all posts are filled and everything should be working. Please help.
<?php
session_start();
include 'dbh.php';
$newname = htmlspecialchars($_POST['nieuwenaam']);
$newprice = htmlspecialchars($_POST['nieuweprijs']);
$oldname = $_POST['oudenaam'];
$oldprice = $_POST['oudeprijs'];
$pid = $_POST['pid'];
if(!isset($newname) && !isset($newprice))
   {
      echo 'hoi';
   }
elseif(!isset($newname) && isset($newprice))
   {
        echo $newprice;
        $sql = "UPDATE producten SET naam = '$oldname' , price = '$newprice' WHERE product_id = $pid";
        $query = $PDO->prepare($sql);   
        $query->execute();
    }
elseif(isset($newname) && !isset($newprice))
    {
        echo $newname;
        $sql = "UPDATE producten SET naam = '$newname' , price = '$oldprice' WHERE product_id = $pid";
        $query = $PDO->prepare($sql);   
        $query->execute();
    }
 
     
     
     
    