I have a product code verification script. How to make it so that after the lightning of a code, it can not be used a second time.
<?php
require_once('captcha.php');
$error = $verified = false;
if($_POST){
mysql_connect('localhost', 'root', 'root');
mysql_select_db('code');
if(!PhpCaptcha::Validate($_POST['captcha'])){
$error = 'Anti-bot code is not valid!';
}else{
$query = "SELECT product_title FROM code1 WHERE code_plain='".mysql_real_escape_string($_POST['code'])."'";
$result = mysql_query($query) or die(mysql_error());
$res = mysql_fetch_assoc($result);
if(mysql_num_rows($result)>0) $verified = $res['product_title'];
else $error = '<b>This poruduct code is not valid or doesn\'t exist!</b>';
}
}
?>