Hi, I need your help with this code please. I have tried a couple of things but none seem to work. I need to check that the client name from amcname input does not exist in the db. Please assist.
________________________________________________________________________________________
//My function code
public function insert($cname, $ccode, $cregno, $cvatno)
{
$sql = "INSERT INTO tbl_client (ccode, cname, cregno, cvatno) VALUES (:amcname,:amccode,:amcregno,:amcvatno)";
$stmt = $this->conn->prepare($sql);
$stmt->execute(['amcname' => $cname, 'amccode' => $ccode, 'amcregno' => $cregno, 'amcvatno' => $cvatno]);
return true;
}
________________________________________________________________________________________
//My Action Code
if (isset($_POST['action']) && $_POST['action'] == "insert") {
$cname = $_POST['amcname'];
$ccode = $_POST['amccode'];
$cregno = $_POST['amcregno'];
$cvatno = $_POST['amcvatno'];
$db->insert($cname, $ccode, $cregno, $cvatno);
}
________________________________________________________________________________________
What I have tried:
I have tried using JS and mysqli with no success.