我不能完全考虑如何使用 mysql 和 php 来做到这一点。基本上我希望能够将数据提交到 mysql 数据库中,但在插入之前,它会检查该条目是否已经存在。
$guid=$_POST['guid'];
$name=$_POST['name'];
//Username
$user="webhost";
//Password
$pass="*******";
//IP To Host
$ip="***********";
//Database
$db="dayz2";
//Table
$table="whitelist";
//Database Connection
$con=@mysql_connect("$ip", "$user", "$pass")
or die(mysql_error());
//Select Database
$dbcon=@mysql_select_db($db, $con)
or die(mysql_error());
$dupesql = "SELECT * FROM $table where (name = '$name' AND guid = '$guid')";
$duperaw = mysql_query($dupesql);
if (mysql_num_rows($duberaw) > 0) {
echo "Entry Already Exists";
}
else {
//Query Data Into Whitelist Table
$sql="INSERT INTO $table (name, guid) VALUES ('$name', '$guid')";
//Submit Data into Whitelist Table
$result=@mysql_query($sql, $con) or die(mysql_error());
}
?>