PHP | Passing Variables to URL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
php_2008
Forum Newbie
Posts: 2
Joined: Fri Jun 27, 2008 2:23 pm

PHP | Passing Variables to URL

Post by php_2008 »

I am using a little jump script that redirects to a particular site based on the variable.

For example:
http://www.mydomain.com/courses/jump.php?o=golfcourse1

Would redirect to:

http://www.newdomainname.com/index.jsp? ... orreyPines

I can get this working fine. But here is where I am stuck...

I'm trying to add additional info to the URL so that it looks like: http://www.domainname.com/index.jsp?Cou ... =MyCookie2


Here is the error I am receiving on the jump page:

Parse error: syntax error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/golf/public_html/golf/courses/jump.php on line 4


Here is the Jump page source code associated with the error message:
<?PHP
$m = $_GET['o'];
if ($m == "") {$link = "www.domainname.com";} // Default Blank
if ($m == "golfcourse1") {$link = "http://www.domainname.com/index.jsp?pag ... emp1=<?php echo ($_COOKIE["MyCookie"]) ?>&temp2=<?php echo ($_COOKIE["MyCookie2"]) ?>";}

header("Location: $link");
exit();
?>

Thanks in advance!
Reviresco
Forum Contributor
Posts: 172
Joined: Tue Feb 19, 2008 4:18 pm
Location: Milwaukee

Re: PHP | Passing Variables to URL

Post by Reviresco »

You have two extra sets of php start and end tags in there.

Code: Select all

<?PHP
$m = $_GET['o'];
if ($m == "") {
    $link = "www.domainname.com";
    } // Default Blank
if ($m == "golfcourse1") {
    $link = "http://www.domainname.com/index.jsp?pageName=Info&temp1=" . $_COOKIE["MyCookie"] . "&temp2=" . $_COOKIE["MyCookie2"] ;
    }
 
header("Location: " .  $link);
exit();
?>
php_2008
Forum Newbie
Posts: 2
Joined: Fri Jun 27, 2008 2:23 pm

Re: PHP | Passing Variables to URL

Post by php_2008 »

Thanks Reviresco! That did the trick.
Post Reply