Website PHP url no longer works.

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
landa
Forum Newbie
Posts: 1
Joined: Sun Nov 11, 2007 8:59 am

Website PHP url no longer works.

Post by landa »

I haven't visited my website in a while, and so I haven't kept up with the PHP changes in the past 2 years. What page URLs used to work, no longer do.
My site used to work with this code:

Code: Select all

<?php $vs = array('disclaimer', 'affiliate', 'linkus');
if( in_array($v, $vs) ) { include($vs);} else{ include "news/news.php";} ?>
however, typing the url http://examplesite.com/main.php?vs=affiliate only returns the news.php page even though "affiliate" is in the array.


since that didn't work (even though it used to), I even tried a very basic code:

Code: Select all

<?php if($vs == "") { include "news/news.php"; } else { include "$vs"; } ?>
type in the same url http://examplesite.com/main.php?vs=affiliate and it still returns the news.php page! even if i put in "disclaimer" or "linkus" in place of "affiliate" in the URL they all return the news.php instead....... and they're all working, existing files on my server.
my site used to work with either line of code until recently. i changed nothing in the coding, but my server did upgrade the PHP scripting/database to the most recent version. did something change that I wasn't aware of? How should I be coding this instead?

the general purpose that i used this line for was... if i specified the page in the URL, then i want that displayed in the body of the page. however, if no page is specified OR if a specified page is NOT in the array (meaning someone visiting the site is typing in random page URLs or trying to exploit the code) then i want it to return the default news page in the body.

can someone help? I'd appreciate it a lot, thanks in advance.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Your code relies on register_globals being on. They, likely, are not.

$_GET['vs'] should be used instead.

Also, be aware that blindly including is extremely dangerous. We've had many topics on performing inclusions based on user input. One is linked from Useful Posts.
Post Reply