【发布时间】:2017-11-29 15:53:58
【问题描述】:
我正在创建一个客户数据库。我在搜索功能中创建错误检查,以便在用户不存在时将用户重定向回搜索页面。我创建一个这样的标题:
header("Location: search.php?search=not-found");
我想在search.php页面上写一个if statement,这样如果URL末尾有"?search=not-found",那么它会显示一个错误,用户可以通过搜索框看到。比如(我知道这是不正确的):
if(url contains ['search.php?search=not-found']){
echo 'That user doesn't exist';
}
else {
echo 'Please search for a user';
}
我该如何写这个 if 语句?
【问题讨论】:
-
你不能直接和
$_GET核对一下吗?像这样的东西:if (isset($_GET['search']) && $_GET['search'] == 'not-found')。 php.net/manual/en/reserved.variables.get.php
标签: php sql database if-statement header