load a div with a page in php [closed]

1

I'm having an error, let's say, primary kkkk

I have a page made in html updated by php.

My problem is loading the contents of a div.

I have text. By clicking on this text it loads the content into a div, only this content is a php page, for example teste.php .

The question is .... How to do this?

NOTE: I have a file, below ( regras.php )

<?php  switch($_GET["pagina"])
	{		
		case  "adestraBasic":
		$var_conteudo="AdestraBasic.php";
		break;	
		case  "advance":
		$var_conteudo="Advance.php";
		break;	
		
	    default: $var_conteudo="AdestraBasic.php";
		
	}
?>

And on the page I have:

<?php include "regras.php";?>

A div:

<div id="PHP">
    <?php include $var_conteudo; ?>
</div>

Page:

<head>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />

</head>

<body>

<div id="wrapper">
	
	<div id="page">
		<div id="page-bgtop">
			<div id="page-bgbtm">
				<div id="content">
					<div class="post">
						<h2 class="title">curso da iron dog</h2>


<div id="PHP">
   <?php include $var_conteudo; ?>
        </div>

					</div>
				</div>
				<!-- end #content -->
				<div id="sidebar">
					<ul>
					  <li> </li>
						
						<li>
	            <h2>Cursos</h2>
							<ul>
	<li><a href="#">1 Adestramento Basico</a></li>
	<li><a href="#">2 Adestramento Avançado</a></li>
	<li><a href="#">3 Agility</a></li>
	<li><a href="#">4 Cães de Policia</a></li>
	<li><a href="#">5 Figurante</a></li>
								
							</ul>
						</li>
						</ul>
						</li>
					</ul>
              </div>
				<!-- end #sidebar -->
				<div style="clear: both;">&nbsp;</div>
			</div>
		</div>
	</div>
	<!-- end #page -->
</div>

</body>
    
asked by anonymous 23.07.2016 / 03:42

2 answers

0

You have to pass via GET the name of the page you want 'rules.php' to receive.

I use the following structure to do this.

Home page:

<?php

//Usuários
$pagina['AdestraBasic'] = "adestra_basic.php";

//Se a variável 'link' for diferente de vazio.
if (isset($_GET["pag"])) 
{
    $link = $_GET["pag"];

    //Se o arquivo da página existir inclui.
    if (file_exists($pagina[$link]))
    {
        include_once $pagina[$link];
    }
    else
    {
        //die (include_once '../includes/pagina_erro.php');
    }
}
//Caso contrário inclui a página 'home'.
else 
{
    //include_once 'home.php';
}

? >

                                                                                         iron dog course                                                                                                      
  •                         
  •                 

    Courses

                                
    • 1 Basic Dressage
    •     
    • 2 Advanced Dressage
    •     
    • 3 Agility
    •     
    • 4 Police Dogs
    •     
    • 5 Figurante
    •                             
  •                         
                                                                                                
<!-- end #page -->

Basic Adress Page:

<?
echo 'Incluiu página adestramento básico!!!';

? >

    
23.07.2016 / 13:10
0

I do the following, I get the page name by GET, and the original name of the files are the same as the possible GETs. It is very basic to include the page:

$pagina = $_GET['pagina'];
//Faz uma validação do link aqui
...


Chama a página no lugar que você quiser
<?php include $pagina . ".php" ?>
    
23.07.2016 / 17:09