Jump to content

PHP die function


scferg

Recommended Posts

There is two reasons for that

 

1) There is a period in the name of the page, which violates our letters/spaces/underscores requirement

2) The script automatically adds .html to the end of it. So even if it got past #1, it would be looking for the page:

news/show_archives.php.html

 

Does the show_archives.php file have to be a .php? or can it be .html?

 

my recommendation is to do the follow:

 

Step 1) Make all your .html files .php instead

 

Step 2) Change the script to:

<?php
  $error_page = "./404.php";
  $page = $_GET['page'];
  $section = $_GET['section'];

  if($page == "case1") { //Handle special cases first
    echo "case1 goes here no page was written for this statement.";
  } elseif($page) { //Page requested
    $path = "{$page}.php";
    if($section) //Add section
      $path = "{$section}/{$path}";
    //Check keys and existance
    if( preg_match('/^\w+$/',$page) && 
        (!strlen($section) || preg_match('/^\w+$/',$section)) && 
        file_exists($path)
      )
      include($path); //Good to go...include it
    else
      include($error_page); //Error page
  } else { //Default
    $number=10;
    $only_active=TRUE;
    include("./news/show_news.php");
  }
?>

 

Step 3) Have the URL for the News Archive be like the others: http://sims2news.com/?section=news&page=show_archives

Ok, I changed my mind...I changed the code and switched the files to .php . It works great now!

 

This is kind of off topic, but just out of curiosity...on my 404.php page, is there a way to display the page requested that has not been found?

 

Like: The page http://sims2news.com/?page=1234 has not been found

 

It's not necessary, but it would be cool if it could

 

Thanks!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.