Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

Include help please!

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
SpaceshipSpaceship
Watch

treyb

Established Member
Impact
2
Ok, Im using
PHP:
<?php if (empty($page)) {
$page = "home.php"; 
}
if (file_exists("$page")) {
  include("$page");
} else {
  echo "<b>404</b> File not found.<br> We are sorry, the requested file cannot be found on our server.";
}
?>
And I try to type in my browser site.com/index.php?page=test.php and the page does not change to the other pages information...
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Actually your method does not really safe.
Lets modify it :)
PHP:
<?php
$page = $_GET['page'];
$page = preg_replace('/([^a-z0-9\-\_]+)/i', '', $page);// remove unwanted char(s)
if (empty($page)) {
   $page = 'home'; 
}
$page .= '.php';// it must be a PHP file
if (file_exists("$page")) {
  include("$page");
} else {
  echo "<b>404</b> File not found.<br> We are sorry, the requested file cannot be found on our server.";
}
?>
 
0
Close
thanks a million rep added!
 
0
Close
Almost forget,
use "site.com/index.php?page=test" instead of "site.com/index.php?page=test.php" :)

Good luck,
- Kurniawan.
 
0
Close
lol i almost asked but then i thought about it and realized i was stupid for not noticing at the begining lol but thank goodness for trial and error lmao
 
0
Close
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back