PHP Question?
- Started
- Last post
- 3 Responses
- Shepstar15
I have something simple and perhaps someone could be so kind and give me some help.
I have a index.php with a php include and would like to change the file that gets included when you click on a link. So when you click company, the include takes the company file, when I click on references it includes thes references file.
Thanks a lot in advance!
- neverblink0
Multiple ways of doing this, easiest with your include-function would be to make the link something like
index.php?page=1
then add a check to your php script, that checks if page is numerical, and if it is, do a switch statement on the number..
if page = 1 include somepage.php
if page = 2 include someotherpage.php
- Shepstar150
Thanks neverblink, I just found a way!
- vaxorcist0
make sure you force validate the variable to a number or something very simple, like you filter out any non-alpha/numeric characters.... otherwise somebody may try to try some mischief
index.php?page=/etc/passwd
or even try to mess you up with a loop like:
index.php?page=index.php
- a clean switch case statement would be okay to prevent such stuff too....vaxorcist