Skip to content
This repository has been archived by the owner on May 27, 2023. It is now read-only.

Commit

Permalink
fix dup sn check for new items
Browse files Browse the repository at this point in the history
  • Loading branch information
Spiros Ioannou committed Oct 25, 2014
1 parent 17c10b3 commit f356ca7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions php/edititem.php
Expand Up @@ -324,11 +324,13 @@ function isvalidfrm() {


$myid=$_GET['id'];
$sql="SELECT id from items where id <> $myid AND ((length(sn)>0 AND sn in ('{$_POST['sn']}', '{$_POST['sn2']}')) OR (length(sn2)>0 AND sn2 in ('{$_POST['sn']}', '{$_POST['sn2']}'))) LIMIT 1";
$sth=db_execute($dbh,$sql);
$dups=$sth->fetchAll(PDO::FETCH_ASSOC);
if (count($dups[0])) {
$err.="Duplicate SN with id <a href='$scriptname?action=edititem&amp;id={$dups[0]['id']}'><b><u>{$dups[0]['id']}</u></b></a>";
if ($myid != "new" && is_numeric($myid) && (strlen($_POST['sn']) || strlen($_POST['sn2']))) {
$sql="SELECT id from items where id <> $myid AND ((length(sn)>0 AND sn in ('{$_POST['sn']}', '{$_POST['sn2']}')) OR (length(sn2)>0 AND sn2 in ('{$_POST['sn']}', '{$_POST['sn2']}'))) LIMIT 1";
$sth=db_execute($dbh,$sql);
$dups=$sth->fetchAll(PDO::FETCH_ASSOC);
if (count($dups[0])) {
$err.="Duplicate SN with id <a href='$scriptname?action=edititem&amp;id={$dups[0]['id']}'><b><u>{$dups[0]['id']}</u></b></a>";
}
}


Expand Down

0 comments on commit f356ca7

Please sign in to comment.