<?php
	session_start();
	if (isset($_SESSION["admin"]["id"])) {

		if ($_GET) {

			include "../config/conf.php";
			$table = trim($_GET["table"]);
			$campo = trim($_GET["campo"]);
			$sub = trim($_GET["sub"]);
			$id = trim($_GET["id"]);

			$x = "";

			if (!empty($id)) $x = " id <> $id AND ";

			$sql = "select * from $table where $x $campo = '$sub' limit 1";
	        $consulta = $db->prepare($sql); 
			$consulta->execute();
			$r = $consulta->fetch(PDO::FETCH_OBJ);

			if (!empty($r->id)) echo "Já existe um cadastro com este valor";

		}
	}