Jump to content
php.lv forumi

Sāpīte - ?lapa=kautkas


Kemito

Recommended Posts

Tā tad sekojoši:

if($GET['lapa'])
{
if(file_exists($GET['lapa'].".php"))
{
include($GET['lapa'].".php");
}
else
{
include('nav.php');
}
}

Ideja ir sekojoša varbūt kādam ir priekšlikums vai koda gabals ar kuru var panākt iznākumu!

index.php?lapa=mansfails

Izveidojot failu mansfails.php

Respektīvi izveidoju failu fails.php tad līdz ar to būs index.php?lapa=fails

Ceru, ka sapratāt! Viens cilvēks teica ka šāds risinājums nav labs:

Citāts no viņa teiktā:

nedrīkst šādi caur getu padot parametru pēc kura nosaka inklūdējamā faila nosaukumu

Paldies!

Link to comment
Share on other sites

ņem

index.php

$pg=$_GET['lapa'];
if (!isset($pg)){
$pg='news';
}
if (file_exists("lapas/".$pg.".php")) {
include("lapas/".$pg.".php");
}
else{print"<div class=\"msg-error\"><ul><li>Not Found.</li></ul></div>";
}

m_protect.inc.php

<?php
if(!isset($pg)){
Die("Wrong Page!");
}
?>

un iekš tiem sub failiem

<?php
include"m_protect.inc.php";
?>

Edited by waplet
Link to comment
Share on other sites

 <?php 
$pg = $_GET['pg'];
if(isset($_GET['pg'])&&$_GET['pg'] != "")
{
if(file_exists('folderis/folderis/'.$pg.'.php'))
{
include('folderis/folderis/'.$pg.'.php');
}
}
else
{include('folderis/folderis/bazaars.php');
}
?> 

 

Linku nosaukumus liec "?pg=kautkas"

 

Attieciigi arii mapes taisi folderis/folderis, kur buus datu faili.

 

Piemeeram ir index.php, shajaa failaa liec to skriptu. Tad uztaisi linkus, piemeram 3 linki -Par mani, kuram links ir "?pg=about", Pakalpojumi, kuram links ir "?pg=services" un Kontakti, kuram links ir "?pg=contacts". Taatad pie index.php staav mape ar nosaukumu "folderis" un ieksh taas mapes ir veelviena mape ar nosaukumu "folderis", kuraa glabaajas faili ar nosaukumiem contacts.php, services.php un about.php.

 

Neder? tad attieciigi arii buus blaablaa.php?pg=kautkas adrese.

 

Vari meegjinaat lietot arii .htaccess vai MOD Rewrite.

Edited by MCWeb.lv
Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...