Kawinma
07-22-2003, 06:44 AM
How would I be able to have something like
index.php?page=somethinfunkyhere
Could you please tell me where I can find the code for this?
Coconut99
07-22-2003, 02:48 PM
Try this:
1) Make sure that your hosts PHP.
2) Open up the main page, where you would have all of content, navigation, etc.
3) Delete all the content. (NOT the navigation.) Now where the content was type this in:
<?php include ("$variable.extension"); ?>
You can change the $variable to whatever you want. It will be shown in the URL. (So in the URL http://www.thisismyurl.com/index.php?page=sting, $variable would be $page.)
The extension part of that is what type of page your site has. .HTM, .HTML and .TXT are the easiest to edit.
4) You have to save the file where you wrote the PHP code above as a .PHP file. You can name it anything you want. (Like index.php or main.php.) Upload it to your server, then open it in your browser.
There will be an error, but that's only because you haven't directed any page to it. If you see an error message, you are on the right track. Don't worry. ;)
5) Now make the page that will be shown when someone goes to index.php?page=somethinfunkyhere. (Somethinfunkyhere.html, or whatever your extension was.) Make it really simple, like this:
<B>This Is A Great Title</B>
<P>This is the best content around.</P>
Save it as test.extension. (Extension meaning whatever you used in step three.) The extensions MUST match. Now upload this page to your web sever.
6) Now visit it, through this URL: index.php?page=test. It SHOULD work. If it doesn't, I'll try to make this tutorial more understandable. :D
Kawinma
07-22-2003, 10:37 PM
Hrm. Dosn't work.
<?php include ("$page.html"); ?>
I'm using a seprate file for it, redirect.php
redirect.php?page=linktous
would have it go to redirect.html, am I correct?
I get these errors:
Warning: main(.html) [function.main]: failed to create stream: No such file or directory in /vhosts/calisto.furcadiawest.eu.org/redirect.php on line 1
Warning: main() [function.include]: Failed opening '.html' for inclusion (include_path='.:/usr/local/php4/lib/php') in /vhosts/calisto.furcadiawest.eu.org/redirect.php on line 1
toosweet4u
07-23-2003, 12:57 AM
$default = 'welcome';
$page = (isset($_GET['page'])) ? $_GET['page'] : $default;
include($page.'.html');
change $default to the page you want to display if $page is not defined.
Coconut99
07-23-2003, 02:40 PM
Sorry I didn't get back to you! (The power was out.) The URL redirect.php?page=linktous would take you to linktous.html, but redirect.php?page=redirect would take you to redirect.html. The reason you got that error was because linktous.html couldn't be found. Remember that in the URL http://www.mydomain.com/index.php?page=hi, hi is the name of the file you want, not index. Hope that helps!
Kawinma
07-23-2003, 11:22 PM
Thanks, both of you.
I'll use both codes on my two seprate sites.