Jump to content

need help making my code secure (only 9 lines)


runnerjp

Recommended Posts

hey guys

 

i use this

 

<?php 
if (isset($_GET['section'])) {
  $section = $_GET['section'];
} else {
  $section = 'main';
}
$file = "include/".$section.".php";
if (file_exists($file)) {
    require($file);
} 
?> 

 

but i dnt seem to think its secure lol

Link to comment
Share on other sites

                <?
                    $page = $_GET['page'];
                    if (ereg('[A-Za-z0-9]',$page) ) {
                        if (file_exists('pages/'.$page.'.php')) {
                            include('pages/'.$page.'.php');
                        } else {
                            include('pages/main.php');
                        }
                    } else {
                            include('pages/main.php');
                    }
                ?>

Link to comment
Share on other sites

no.. For example:

You have folder "pages". In this folder you have several PHP files:

pages/main.php

pages/news.php

pages/compare.php

 

To call this files you have to call it thru URL : index.php?page=main or index.php?page=news or index.php?page=compare

 

All files should have *.php extension.

The name of file should consists only from A-Z a-z 0-9

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.