[php] "?op="

Joined
Apr 22, 2006
Messages
16
Reaction score
0
Im expern in html, but noob in php. (learning it)
(Code by =Master= MuWeb v0.8)
function modules(){
if(isset($_GET['op'])){
$op = $_GET['op'];

if (is_file("modules/".$op.".php")) {
include("modules/".$op.".php");

} else {
require("config.php");
Echo ("<br>$warning_start Module Could Not Be Found By MuWeb! $warning_end<br>");
}
}
}

How to make that in switch? and where should i put that ? library or something? Or say me a better way to do that.
 
ok got that out myself

<?php
$content = "";
$link = "<a href=\"index.php?id=1\">Link</a>";
if (isset($_GET["id"])) $id = $_GET["id"];
switch ($id) {
case "1";
$content = include ("link.php");
$link = "";
break;
}
?>
<?php echo $error;
echo "<br>";
echo $link;
?>

lol is it righ? and can someone hack it?
 
k now i want to know which code is better and why ;/

will i have problems changing content like that:

++++++++++++++++++++++++++++++
- -
- Banner -
-+++++++++++++++++++++++++++++
+$Link1++---------------------------+
+$Link2++----------$Content--------+
+$Link3++---------------------------+
+$Link4++---------------------------+
+$Link8++---------------------------+
-------------------------------------+
 
Try something like this,
Code:
<?php
$op = $_GET['op'];
switch ($op) {
	case $op:
    $content = $op . '.php';
    break;
    default:
    $content = 'index' . '.php';
    break;
}
if (is_file($content)) {
	include($contetnt);
} else {
	echo 'File couldn\'t be found.';
}
?>
 
(mistake on line 11 but nwm)
so it gonna be page index but page content will be in $content.php ?

the point is what i putted everything in panels. (nav_panel.php, login_panel.php, content_panel.php and other) I want to page always be we same (index.php), because in index.php are all panel requests, i only need to change content of the page. In content_panel.php i want to make variable $content and it will display ?op=link (link's) content. Got it?

OMFG srry for english :DDDDDd
 
Hmm.. Then on the top and bottom of the script just put the script for index and the center just add the script that include the content.

You just have to name the file, let's you have one content and you named it as 'contact_content' then you should save the file as contact_content.php then you can see the file through the link http://yourlink/?op=contact_content
 
The switch works like that:

$somevar = $_GET['some_link'];

switch ($somevar){
case "blablabla":
do this;
do this;
do that;
break;
case "blebleble":
do this;
do that;
break;
case "123":
do what i say;
execute it;
break;
default:
echo "The variable is empty or doesn't match any case. Try again.";
break;
}


This is how SWITCH works.
=]
 
Don't forget to disallow includement of the file it self to avoid overloading/mass looping
 
Back