【发布时间】:2018-01-22 22:16:37
【问题描述】:
我正在尝试使用 php 检查我的数据库以查看是否存在值。我的主要目标是使用这个值
$_GET['UDID']
如果它等于数据库中的任何值,它将返回
echo 'FOUND';
我正在使用此代码:
<?php
$servername = "*****";
$username = "*****";
$password = "*****";
$dbname = "*****";
$connect = new mysqli($servername, $username, $password, $dbname);
if ($connect->connect_error) {
die("CONNECTION FAILED: " . $connect->connect_error);
}
$udid = $_GET['UDID'];
$id = mysqli_real_escape_string($connect, $udid);
$result = mysqli_query($connect, "SELECT udid FROM data WHERE udid = '$id'");
if($result === FALSE) {
die("ERROR: " . mysqli_error($result));
}
else {
while ($row = mysqli_fetch_array($result)) {
if($row['udid'] == $udid) {
$results = 'Your device is already registered on our servers.';
$results2 = 'Please click the install button below.';
$button = 'Install';
$buttonlink = 'https://**link here**';
}
else {
$results = 'Your device is not registered on our servers';
$results2 = 'Please click the request access button below.';
$button = 'Request Access';
$buttonlink = 'https://**link here**';
}
}
}
?>
但由于某种原因它无法正常工作,我确信我正在寻找一些东西。非常感谢您的帮助。
【问题讨论】:
标签: php html sql database mysqli