Te servirá algo así:
Código PHP:
<?
$sql = mysql_query("SELECT algo FROM tabla WHERE campo='".$algo."'");
if($row = mysql_fetch_array($sql)) {
echo "ok"; // O pones un header() a datos.php, aunque si lo haces aquí casi que mejor.
} else {
header("Location: http://www.ir.a/noexiste.php");
}
?>