i need to check the database and see wether the information i'm about to enter doesn't already exist. what's the best way to do that?
here's the code i'm using to insert the new data. but before that i should see wether either one (the cod "cod" or the name) is already there.
here's the code i'm using to insert the new data. but before that i should see wether either one (the cod "cod" or the name) is already there.
Code:
<?php
include('dbcon.php');
if (!empty($_GET[cod]) && !empty($_GET[name])) {
$query = "INSERT INTO mytable VALUES ('$_GET[cod]', '$_GET[name]')";
$result = mysql_db_query("mydbase", $query);
if ($result) {
echo "<p>Name $_GET[name] was add</p>";
echo "<p>with cod : $_GET[cod] .</p>";
}
}
else{ echo " there are empty fields ";
}
?>