TranceAddict Forums (www.tranceaddict.com/forums)
- Chill Out Room
-- Need some help with PHP
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?
Noone with any ideas?
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.
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.
| 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. |
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");
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.
| 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. |
| quote: |
| Originally posted by DJ RozzeR wtf it posted it twice , wierd |

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

| 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. |
| quote: |
| Originally posted by nekholm Inside I assume? What else, I tried it but it didn't work.. ![]() |
code:
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.