【发布时间】:2014-04-16 18:14:49
【问题描述】:
好的,前几天我在这里发帖,帮了很多忙,所以我决定回来。我对相同的代码有另一个问题。我想向它添加另一个我使用的源 = "$location_url2" 然后我添加了第二个 "$content" 以匹配代码。两个来源之间的区别是“$location_url”如果没有找到则返回一个空白页面,但“$lcation_url2”如果没有找到则重定向到 index.php,但保留 url 上的扩展名......我的代码使用:
<?php
if(isset($_POST['search'])) {
$search_text = $_POST['search'];
$location_url = "http://cydia.saurik.com/package/{$search_text}/";
$location_url2 = "http://rpetri.ch/cydia/{$search_text}/";
$content = @file_get_contents($location_url);
$content2 = @file_get_contents($location_url2);
if($content) {
header("Location: {$location_url}");
} else if($content2) {
header("Location: {$location_url2}");
} else {
header("Location: suggest.php");
}
}
?>
HTML 代码:
<div id="content">
<div id="search">
<form method="POST" name="search" action="search.php">
<input type="text" name="search" name="placeholder" placeholder="Search Tweaks..."/>
<input type="submit" name="submit" value="Search"/>
</form>
</div>
</div>
【问题讨论】:
标签: php html search redirect location