Last active
December 26, 2015 06:59
-
-
Save gubi/7111875 to your computer and use it in GitHub Desktop.
This script finds searched pages to similar existing and redirect users to correct page if the result is 1.
Use PDO connection.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$page = addslashes($_GET["p"]); | |
$searching_page = $pdo->query("select * from `TABLE` where `COLUMN` sounds like '%" . $page . "%'"); | |
if($searching_page->rowCount() == 1) { | |
while($dato_searching_pages = $searching_page->fetch()) { | |
header("Location: " . $dato_searching_pages["COLUMN"]); | |
exit(); | |
} | |
} else { | |
$searching_page = $pdo->query("select * from `TABLE` where `COLUMN` sounds like '%" . $page . "%'"); | |
if($searching_page->rowCount() > 1) { | |
$content_page = "<section><p>The page you're looking for do not exists :(<br />Maybe you're looking for:</p><ul>"; | |
while($dato_searching_pages = $searching_page->fetch()) { | |
$content_page .= '<li><a href="./' . $dato_searching_pages["COLUMN"] . '">' . $dato_searching_pages["COLUMN"] . '</a></li>'; | |
} | |
$content_page .= "</ul></section>"; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment