I have this variable $nombrecat and I want to INSERT it into the table categories in the column category. But before that I want to check if already exists. This is my current code:
$nombrecat = $_POST['crearcat'];
$cmd = $connect -> prepare('INSERT INTO  `categories` (`category`) VALUES (:nombrecat)');
$cmd ->bindParam(':nombrecat',$nombrecat);
$cmd -> execute();
I want to check if  $nombrecat exists. If it does, do nothing, if it doesn't, execute my code above. How can I achieve this?
