content.php switch
Discutii despre script-uri si coduri PHP-MySQL, precum si lucru cu XML in PHP.
-
Komfort
- Mesaje:157
content.php switch
index.php
Cod: Selectaţi tot
<?php
include 'style.php';
echo
'<div style="position:absolute;top:5px;left:37%"><img src="head1.jpg"></div>
<div style="position:absolute;top:324px;left:37%"><img src="head2.jpg" style="opacity:1;filter:alpha(opacity=100)" onmouseover="this.style.opacity=0.6;this.filters.alpha.opacity=50 " onmouseout="this.style.opacity=1;this.filters.alpha.opacity=100" ></div>
<div style="position:absolute;top:460px;left:37%"><img src="head3.jpg"></div>';
echo ' <!--Meniu-->';
echo '<div style="position:absolute;top:330px;left:39%"><font size=4><b><a href="index.php?pagina=a">Home</a></b></font></div>
<div style="position:absolute;top:353px;left:39%"><font size=4><b><a href="regulament.php?pagina=b">Regulament</a></b></font></div>
<div style="position:absolute;top:376px;left:39%"><font size=4><b><a href="login.php?pagina=c">Login</a></b></font></div>
<div style="position:absolute;top:399px;left:39%"><font size=4><b><a href="register.php?pagina=d">Register</a></b></font></div>
';
include 'content.php';
?>
content.php
Cod: Selectaţi tot
<?php
switch($pagina){
case a: include 'index.php';
case b: include 'regulament.php';
case c: include 'login.php';
case d: include 'register.php';
}
?>
de ce nu merge?
imi apare de ex cand dau click pe regulamet.php
imi apare doar ce e in regulametn .php si trebe cu tot cu ce e in index
unde am gresit?
MarPlo
Mesaje:4343
In "regulametn .php" e inclus "index.php", cu include()?
Sau ar trebui link-ul de la Regulament cu adresa la fisierul "index.php"
Komfort
Mesaje:157
<a href="regulament.php?pagina=b">Regulament</a>
nu ar fi logic asa?:|
MarPlo
Mesaje:4343
Adresa "regulament.php?pagina=b" deschide fisierul "regulament.php", dar fiindca switch-ul cu include e in "content.php", care e inclu in "index.php", pentru a face ce vrei trebuie accesat fisierul index.php.
Komfort
Mesaje:157
oare e bun cum am facut la content.php?
nikuu2
Mesaje:22
Salut! Incearca asa:
Index.php
Cod: Selectaţi tot
<?php
include 'style.php';
echo
'<div style="position:absolute;top:5px;left:37%"><img src="head1.jpg"></div>
<div style="position:absolute;top:324px;left:37%"><img src="head2.jpg" style="opacity:1;filter:alpha(opacity=100)" onmouseover="this.style.opacity=0.6;this.filters.alpha.opacity=50 " onmouseout="this.style.opacity=1;this.filters.alpha.opacity=100" ></div>
<div style="position:absolute;top:460px;left:37%"><img src="head3.jpg"></div>';
echo ' <!--Meniu-->';
echo '<div style="position:absolute;top:330px;left:39%"><font size=4><b><a href="'.$_SERVER['PHP_SELF'].'?pagina=a">Home</a></b></font></div>
<div style="position:absolute;top:353px;left:39%"><font size=4><b><a href="'.$_SERVER['PHP_SELF'].'?pagina=b">Regulament</a></b></font></div>
<div style="position:absolute;top:376px;left:39%"><font size=4><b><a href="'.$_SERVER['PHP_SELF'].'?pagina=c">Login</a></b></font></div>
<div style="position:absolute;top:399px;left:39%"><font size=4><b><a href="'.$_SERVER['PHP_SELF'].'?pagina=d">Register</a></b></font></div>
';
if (isset($_GET['pagina'])&&$_GET['pagina']!=""){
$pagina=$_GET['pagina'];
include 'content.php';
}
?>
content.php
Cod: Selectaţi tot
<?php
switch($pagina){
case "a": include 'index.php'; break;
case "b": include 'regulament.php'; break;
case "c": include 'login.php'; break;
case "d": include 'register.php'; break;
}
?>