note 88633 modified in control-structures.switch by danbrown
| From: | danbrown@php.net | Date: | Mon, 02 Feb 2009 19:18:46 +0000 |
| Subject: | note 88633 modified in control-structures.switch by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-150120@lists.php.net to get a copy of this message | ||
you may use the safe list for form variables.. like that,
<?php
switch($_GET['filename']) {
case "mainpage":
case "blabla":
case "blahbla":
break;
default:
$_GET['filename'] = "mainpage";
}
?>
now we can use safety
<?php
$file=fopen("pages/".$_GET['filename'].".html", "w");
// ....
// ..
?>
--was--
you may use the safe list for form variables.. like that,
switch($_GET['filename']) {
case "mainpage":
case "blabla":
case "blahbla":
break;
default:
$_GET['filename'] = "mainpage";
}
now we can use safety
$file=fopen("pages/".$_GET['filename'].".html", "w");
....
..
http://php.net/manual/en/control-structures.switch.php