Simple Question(I think)

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
fall0utm0dd
Forum Newbie
Posts: 3
Joined: Fri Jun 18, 2010 12:38 pm

Simple Question(I think)

Post by fall0utm0dd »

I'm trying to make a text based RPG online, and I just want a simple script in continue.php that redirects players to 'Location'.html, which is set by a cookie named Location.

Code: Select all

header( "Location: http://www.mysite.com/" . $_COOKIE['Location'] . ".html" ) ;
When I try to use it it just takes me to www.mysite.com/.html, which of course throws an error. The cookie does have a value, I checked, so why is it just ignoring the variable?
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Simple Question(I think)

Post by AbraCadaver »

It's not. Just before your header(), do:

Code: Select all

die($_COOKIE['Location']);
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
fall0utm0dd
Forum Newbie
Posts: 3
Joined: Fri Jun 18, 2010 12:38 pm

Re: Simple Question(I think)

Post by fall0utm0dd »

It stays on continue.php, but I know Location has a value because in the cookie editor it says it has the value of 'start', which is what it should have...
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Simple Question(I think)

Post by AbraCadaver »

fall0utm0dd wrote:It stays on continue.php, but I know Location has a value because in the cookie editor it says it has the value of 'start', which is what it should have...
I don't have any idea what the cookie editor is, but if you echo it and it doesn't display anything, then it doesn't have a value. The problem may be where you set the cookie value. If you set it on a page then it won't be available until the next page load or refresh.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
fall0utm0dd
Forum Newbie
Posts: 3
Joined: Fri Jun 18, 2010 12:38 pm

Re: Simple Question(I think)

Post by fall0utm0dd »

Got it working. Imbecilic tutorial template for setting a cookie didn't explain that specifying a site that it can be used on doesn't include all subdirectories.
Post Reply