Log in

View Full Version : out.php?type=rss



hmsnacker123
04-25-2008, 11:35 AM
hi, i need a php script written for me where if in the address bar it says out.php?type=rss it will redirect to my rss feed (which is default.xml). thanks in advance

jc_gmk
04-25-2008, 01:48 PM
This will redirect to a specific page:


$type = $_GET['type']; // This will store the info from the url in a variable

if ($type == "rss")
{
header('Location: http://www.whatever.com/default.php');
}

Where as this will include the page:


$type = $_GET['type']; // This will store the info from the url in a variable

if ($type == "rss")
{
include('default.php');
}


Hope that helps!

Nile
04-25-2008, 01:56 PM
You can also do this:


$type = $_GET['type'];
switch($type){
case 'rss':
include($type.'.php');
break;
default:
echo "Your not on a page!";
}

hmsnacker123
04-25-2008, 02:36 PM
thanks nile

Nile
04-25-2008, 02:37 PM
Anytime.
;)

hmsnacker123
04-25-2008, 02:45 PM
ok guys one more thing i need one to go :

download.php?file=example.zip

jc_gmk
04-25-2008, 02:51 PM
you can use the same script just replace some of the words.

Instead of $type use $file.

Might be worth having a read of this.

http://www.w3schools.com/php/default.asp

It will give you a pretty good insight into PHP.

Nile
04-25-2008, 03:22 PM
Try this:


$type = $_GET['type'];
switch($type){
case 'example.zip':
echo '<a href="$type">Example.zip</a>';
break;
case 'example2.zip':
echo '<a href="$type">Example2.zip</a>';
break;
default:
echo "Your not on a page!";
}

fileserverdirect
04-26-2008, 03:15 AM
Or Even:


$file = $_GET['file'];
if(file_exists($file")
{
header("location: $file");
}
else
{
echo "We're sorry, that file is not available.";
}


;)