I've made a shorten url website. But the thing is not working. I can't include a file. It works and redirects if I go directly using a url.
my handler page code is
<?php
plink = explode('/',$_GET['p']);
//print_r($plink);
include ($_SERVER['DOCUMENT_ROOT'].'/core/config/file.php');
$code = $_GET['p'];
$query = mysql_query("SELECT * FROM shortenurl WHERE code = '$code'");
$numrows = mysql_num_rows($query);
if($numrows == 1){
$row = mysql_fetch_assoc($query);
$url = $row['url'];
// header ("Location: $url");
}
//starts url masking
if (isset($_GET['p']))
{
switch($_GET['p'])
{
// pages set for common interface
case 'home':
include "pages/home.php";
break;
case $code:
include ($_SERVER['DOCUMENT_ROOT'].'/core/pages/redirect.php?r=$url');
break;
//defualt page 404 Error page is set
default;
include ($_SERVER['DOCUMENT_ROOT'].'/errorpages/404.php');
break;
}
}?>
I have added google in database and shorten url in localhost is "site.com/AasfAS"
but I'm getting the following error
Warning: include(C:/xampp/htdocs/core/pages/strg_rd.php?r=googlesite): failed to open stream: No such file or directory in C:\xampp\htdocs\core\pagehandler.php on line
Warning: include(): Failed opening 'C:/xampp/htdocs/core/pages/strg_rd.php?r=googlesite' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\core\pagehandler.php on line "
but if I go to the url /core/pages/strg_rd.php?r=googlesite
it redirects me to the google website
How do I solve this?
Change your code to this.
case $code:
$_GET['r'] = $url;
include ($_SERVER['DOCUMENT_ROOT'].'/core/pages/redirect.php');
break;