Dynadot โ€” .com Transfer

[PHP] index.php? Question

Spacemail by SpaceshipSpacemail by Spaceship
Watch

brizzad

Established Member
Impact
2
Alright.. I'm sure you guys have all seen scripts where all navigation is controlled through index.php

ex:
index.php?mode=register would get the person to register.php

Well, I'm trying to get a script installed, everything seems to be working fine.. except.. none of the links work. All of the navigational links work through index.php like mentioned above, but every single one just brings me back to the index.php main homepage.

any suggestions?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable Domains โ€” AI StorefrontUnstoppable Domains โ€” AI Storefront
It's difficult to tell without knowing the script in question.
Could you show some code ?
 
0
•••
What script are you using? One of your own? We will need a look at a bit mof code most likely, unless there may be an incorrect php setting...
 
0
•••
If you're using a switch($_GET['mode']) statement, it should work fine.

But it's hard to diagnose anything without your current code.
 
0
•••
yeah the link that is found in the "page" part of www.abc.com/index.php?page=home

could be gotten by calling $_GET['page'].

then using that, u cud concatenate it with a file path and use it to open the appropriate file.

but as others said, we need some code to work with.
 
0
•••
Here's an example of how to use it. This simple one will display HTML included by the php function include(). All you have to do is make the pages....and they can be HTML.

PHP:
<?php
switch ($_GET[mode]) {
case "register": //show them the registration page
include("./register.html"); break;

case "login": //show them the login page
include("./login.html"); break;

//and so on until you have enough...

default: //if none of the above applied...
include("./home.html"); break;
} ?>

Of course the above code just inputs the .html pages, and doesn't redirect them. So typing http://www.example.com/index.php?mode=register will only SHOW them the registration page, not REDIRECT them. These .html pages can also be changed into php pages, no problem!
 
0
•••
Here's a modified version of the code that cx409 posted. I use it personally.

PHP:
<?php 
switch ($_GET['mode']) { 
case "": 
case "index": 
include "index.php";
break; 
default: 
include $mode.".html";
break; 
} 
?>
 
0
•••
here's a modified one i use
example index.php?page=register

PHP:
$page = $_GET['page'];
if(!empty($page)){
  if (file_exists($page . ".php")) {
     include($page . ".php"); 
  }else{
     echo '<p class="error" align="center">File not found</p>';//some error message
  }					
}else{
     include("home.php");//or some other default doc
}
 
0
•••
@ cx409

Are you sure include() can handle relative paths? I always thought it can only work with absolute file paths.?
 
0
•••
Nope. include, include_once, require, and require_once all work with relative paths.
 
0
•••
Hmmmz, well tnx for clearing that up!
 
0
•••
Oops, please disregard this post :D
 
0
•••
so much input and he doesn't even respond...
 
0
•••
He's starting his own PHP Development company as we speak ...
First Module : Page navigation
 
0
•••
Dynadot โ€” .com TransferDynadot โ€” .com Transfer
Appraise.net
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back