Loading another Web-Page from php?

Programming, for all ages and all languages.
Post Reply
Perica
Member
Member
Posts: 454
Joined: Sat Nov 25, 2006 12:50 am

Loading another Web-Page from php?

Post by Perica »

..
Last edited by Perica on Sun Dec 03, 2006 9:01 pm, edited 2 times in total.
AGI1122

Re:Loading another Web-Page from php?

Post by AGI1122 »

Try this:

Code: Select all

<?php
if ($HTTP_GET_VARS['action'] == 'forum') {
  header('Location: http://www.mysite.com/forum/index.php');
}
?>
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:Loading another Web-Page from php?

Post by distantvoices »

chris, isn't it possible to access this variable directly by this way:

<?php
if($action == 'xxx') do_sth();
?>
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
AGI1122

Re:Loading another Web-Page from php?

Post by AGI1122 »

Not necessarily, if register globals is set to off in the php.ini file, your code that you just put would not only not work, but give errors.

Also your way is more insecure, it opens up the php script to hacking.
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:Loading another Web-Page from php?

Post by distantvoices »

Hm ... then I should ask My Web Provider to change this ... or would it suffice to replace direct access to the variables extracted by the server out of http-header/body by $HTTP_GET_VARS['my_var']?
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
AGI1122

Re:Loading another Web-Page from php?

Post by AGI1122 »

Well as long as you use the $HTTP_POST_VARS, $HTTP_GET_VARS, $HTTP_SERVER_VARS, you won't have to worry about people hacking your software by poisoning the variables.

The reason why $action won't work is because $action could be set up from a post var or server var, even though it is SUPPOSED to come from the get vars. So it is much safer to do it like this. :)
aedtl

Re:Loading another Web-Page from php?

Post by aedtl »

You guys need to upgrade to PHP 4.1.0.
Then you could use $_GET, $_POST, $_SERVER.
AGI1122

Re:Loading another Web-Page from php?

Post by AGI1122 »

The only reason I told him to use HTTP_GET_VARS, HTTP_POST_VARS and HTTP_SERVER_VARS is because I don't know what version of PHP he has.

I always use $_GET $_POST and $_SERVER in my php scripts, but the code I gave him works better on old and new versions of PHP, well for now anyway, it will be obsolete sooner or later.
Post Reply