Unstoppable Domains

Include help please!

Spaceship Spaceship
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
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
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
•••
thanks a million rep added!
 
0
•••
Almost forget,
use "site.com/index.php?page=test" instead of "site.com/index.php?page=test.php" :)

Good luck,
- Kurniawan.
 
0
•••
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
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99
Appraise.net

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back