We’d like to remind Forumites to please avoid political debate on the Forum.
This is to keep it a safe and useful space for MoneySaving discussions. Threads that are – or become – political in nature may be removed in line with the Forum’s rules. Thank you for your understanding.
📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!
PHP Redirection Help
MBNewB
Posts: 151 Forumite
in Techie Stuff
I am trying to pass two variables from a link on a page and have the link visit certain pages / websites depending on the variables.
My code is below and is not working correctly.
Test2 works fine, and redirects, but Test fails to include the second PHP variable correctly and I don't have enough PHP knowledge to solve the problem myself.
Any help apprecaited
[php]<?php
// The link below is on my website and includes variables, static at the moment just for testing
// <a href="goto.php?site=Test&user=Username">Test</a>
$test = $_GET;
$site = $_GET;
if ($site == "") !!$link = "http://www.homepage.com/";}
if ($site == "Test") !!$link = "http://www.test.co.uk/'. $test .'";}
if ($site == "Test2") !!$link = "http://www.test2.co.uk/";}
header("Location: $link"); // Tells script to goto relevant link
exit();
?>[/php]
My code is below and is not working correctly.
Test2 works fine, and redirects, but Test fails to include the second PHP variable correctly and I don't have enough PHP knowledge to solve the problem myself.
Any help apprecaited
[php]<?php
// The link below is on my website and includes variables, static at the moment just for testing
// <a href="goto.php?site=Test&user=Username">Test</a>
$test = $_GET;
$site = $_GET;
if ($site == "") !!$link = "http://www.homepage.com/";}
if ($site == "Test") !!$link = "http://www.test.co.uk/'. $test .'";}
if ($site == "Test2") !!$link = "http://www.test2.co.uk/";}
header("Location: $link"); // Tells script to goto relevant link
exit();
?>[/php]
0
Comments
-
What error does it give, or does it pass the URL as something like http://www.test.co.uk/%20test ?
Try
if ($site == "Test") !!$link = "http://www.test.co.uk/".$test.;}
JoelFreeBSD | Microsoft | Linux Nerd
GNU-PG Key-ID: 0xCBC2F26D
BSc MBCS MCP0 -
That's the one...
I will try your variation later today when I get home and let you know. Thanks for the help
0 -
What error does it give, or does it pass the URL as something like http://www.test.co.uk/ test ?
Try
if ($site == "Test") !!$link = "http://www.test.co.uk/".$test.;}
Joel
Sorry,
It should be if ($site == "Test") !!$link = "http://www.test.co.uk/".$test ;}
Without the extra .
Joel
FreeBSD | Microsoft | Linux Nerd
GNU-PG Key-ID: 0xCBC2F26D
BSc MBCS MCP0 -
Thanks Joel, worked a treat

Now to learn how to implement that into links within joomla! lol
Thanks again!0 -
Hi, guys
Free and opensource php redirection script I found at PHPKode.com0
This discussion has been closed.
Confirm your email address to Create Threads and Reply
Categories
- All Categories
- 352.5K Banking & Borrowing
- 253.7K Reduce Debt & Boost Income
- 454.5K Spending & Discounts
- 245.5K Work, Benefits & Business
- 601.4K Mortgages, Homes & Bills
- 177.6K Life & Family
- 259.4K Travel & Transport
- 1.5M Hobbies & Leisure
- 16K Discuss & Feedback
- 37.7K Read-Only Boards