Undefined variable problem

A

Anonymous

Guest
jsad said:
The problem is it says type variable is not defined. When I type in http://localhost/content.php?type=about I get thel text from error.html(this is a custom "this page does not exist" I made) and the $type variable error. I'm using IIS on my XP comp. I checked the FAQ and web again but couldn't determine the error.

First question, I don't understand how to define the type variable.
Second question, is this array deal the best way to do what I want to do.
Thanks for any help.

dude, to get the values from the get method use $_GET['type']
so..
Code:
 if ( in_array($_GET['type'],$allowed) ) {

and yess thats pretty much the method, but, if soembody puts a wrong type, you are screwed, so I would suggest a switch case, with a default page.
 
jsad said:
<?php
// Includes we'll allow
$allowed = array('about','links','support');

// If called upon include is allowed, include it.
if ( in_array($_GET['type'],$allowed) ) {

// Using .php as our extention
include $type .'.php';

// Else use default.php as $allowed is not allowed.
} else {

include 'error.php';
}
?>

change to
Code:
<?php 
  // Includes we'll allow
    $allowed = array('about','links','support'); 

  // If called upon include is allowed, include it.     
    if ( in_array($_GET['type'],$allowed) ) { 
  
  // Using .php as our extention
      include $_GET['type'] .'.php'; 

  // Else use default.php as $allowed is not allowed.
    } else {

      include 'error.php';
    }
  ?>
 
Back
Top