Hey everyone having some troubles here with an update statement. I want to update a value(scanISN) if it exists and show information updated and if it doesn't exist show an error right now it show information updated even if it doesn't exist. How would I do that?
<?php if(!isset($_POST['addMe'])){ //show form include_once('View/Scan.html.php'); }else{ //process the form //connect to the database include('Model/DBAdapter.php'); //values to store in RMA Database $receiveDate = date('Y-m-d'); $rmaStatus = "Received"; $scanISN = htmlspecialchars($_POST['scanISN'], ENT_QUOTES, 'UTF-8'); //create sql query $sql = ("UPDATE RMA SET Received_Date = '$receiveDate', RMA_Status = '$rmaStatus' WHERE Unit_Serial_Number = '$scanISN'"); $result = $connection->query($sql); if(!$result){ //ISN Does not exist $output = "ISN does not exist please contact support"; }else{ $output = "RMA information updated."; } include('View/Scan.html.php'); }