TranceAddict Forums

TranceAddict Forums (www.tranceaddict.com/forums)
- Chill Out Room
-- Need some help with PHP


Posted by nekholm on Nov-18-2003 09:46:

Need some help with PHP

I'm making some kinda personal page with PHP, and there's one thing I don't know how to do. It should be really simple, but I just can't figure out how to do it..

The thing is, I use include("$view.php"); => nek.php?view=whatever, and if someone goes to mypage/whatever.php, I want it to forward/redirect the visitor to mypage/nek.php?view=whatever.

I tried it with javascript (if (top.location.href != nek.php?view=test ) top.location.href = nek.php?view=test). It didn't work tho, it kept refreshing the page over and over again. But it almost worked So it could be done in a quite similar way I guess.

Anyone with ideas on how to make this work with either PHP or javascript?


Posted by nekholm on Dec-03-2003 12:10:

Noone with any ideas?


Posted by Rostros on Dec-03-2003 12:34:

I dont think it is possible to run a Javascript in a php script, i maybe wrong i know i had problems when i used js with php, i would look at php dev sites and on google too.


Posted by Rostros on Dec-03-2003 12:34:

I dont think it is possible to run a Javascript in a php script, i maybe wrong i know i had problems when i used js with php, i would look at php dev sites and on google too.


Posted by Rostros on Dec-03-2003 12:35:

quote:
Originally posted by Rostros
I dont think it is possible to run a Javascript in a php script, i maybe wrong i know i had problems when i used js with php, i would look at php dev sites and on google too.


wtf it posted it twice , wierd


Posted by loconet on Dec-03-2003 13:35:

in whatever.php, assuming theres no ouput b4..

code:
$fname = basename($_SERVER['PHP_SELF']); $view = substr($fname,0,strpos($fname,".")); header("Location: mypage/nek.php?view=$view");


Posted by Mr Game+Watch on Dec-03-2003 15:11:

Not sure of the PHP implementation (I'm a ColdFusion programmer myself)... but can you have a page that extracts the URL paramater (in this case "view"), and then $include(URL Paramater) dynamically... You shouldn't even need to worry about javascript.


Posted by nekholm on Dec-03-2003 17:15:

quote:
Originally posted by DJ RozzeR
I dont think it is possible to run a Javascript in a php script, i maybe wrong i know i had problems when i used js with php, i would look at php dev sites and on google too.


Maybe not, I don't know. I've tried to search, but the problem is I don't really know what to search for..

quote:
Originally posted by DJ RozzeR
wtf it posted it twice , wierd


And instead of edit the second post, you post a third time

quote:
Originally posted by loconet
in whatever.php, assuming theres no ouput b4..

code:
$fname = basename($_SERVER['PHP_SELF']); $view = substr($fname,0,strpos($fname,".")); header("Location: mypage/nek.php?view=$view");


Inside I assume? What else, I tried it but it didn't work..

quote:
Originally posted by Mr Game+Watch
Not sure of the PHP implementation (I'm a ColdFusion programmer myself)... but can you have a page that extracts the URL paramater (in this case "view"), and then $include(URL Paramater) dynamically... You shouldn't even need to worry about javascript.


Did I mention I'm quite new to PHP, I only know some very simple stuff? In other words, I have no idea how that would work..


Posted by loconet on Dec-03-2003 17:34:

quote:
Originally posted by nekholm


Inside I assume? What else, I tried it but it didn't work..



Yes inside .

I tested having test.php as:

code:



it redirects to /index.php as:
/index.php?view=test

do you get an error message?


Posted by nekholm on Dec-03-2003 18:38:

That actually works I tested it, but I used $p instead of $view on another page, so I just forgot to change $view to $p. But yes it works. Thanx alot



Powered by: vBulletin
Copyright © 2000-2021, Jelsoft Enterprises Ltd.