Ver Mensaje Individual
  #5 (permalink)  
Antiguo 21/04/2008, 09:16
Avatar de .php
.php
 
Fecha de Ingreso: julio-2006
Mensajes: 481
Antigüedad: 17 años, 9 meses
Puntos: 5
Re: Formulario PHP+Javascript no me envía información

si quieres, trabaja con esta clase, te separa el php del html

Código PHP:
<?
define
("INCLUDE_PATH","./template/");
/* USO
<?
define("INCLUDE_PATH","c:\www\\");

include("template/class.php");

al Pasar como parametro holaMundo, asumimos que en la carpeta 
plantillas existe un archivo de nombre holaMundo.tpl


$html = new Template("ejemplo");
$html->vars(array(
        "variable" => $contenido_variable
));
$html->show(); // Muestra el contenido altiro


$var = $html->add(); // Asigna el contenido a una variable, asi podemos anidar contenidos


?>
*/
class Template{
        function 
Template($template_file){
                
$this->tpl_file INCLUDE_PATH$template_file '.tpl';
        }
        
        function 
vars($vars){
                
$this->vars= (empty($this->vars)) ? $vars $this->vars $vars;
        }
        
        function 
show(){
                if (!(
$this->fd = @fopen($this->tpl_file'r'))) {
                        echo 
'Error al abrir el Template <b>' $this->tpl_file"</b><br />";
                } else{
                        
$this->template_file fread($this->fdfilesize($this->tpl_file));
                        
fclose($this->fd);
                        
$this->mihtml $this->template_file;
                        
$this->mihtml str_replace ("'""\'"$this->mihtml);
                        
$this->mihtml preg_replace('#\{([a-z0-9\-_]*?)\}#is'"' . $\\1 . '"$this->mihtml);
                        
reset ($this->vars);
                        while (list(
$key$val) = each($this->vars)) {
                                $
$key $val;
                        }
                        eval(
"\$this->mihtml = '$this->mihtml';");
                        
reset ($this->vars);
                        while (list(
$key$val) = each($this->vars)) {
                                unset($
$key);
                        }
                        
$this->mihtml=str_replace ("\'""'"$this->mihtml);
                        echo 
$this->mihtml;
                }
        }
        function 
add(){
                if (!(
$this->fd = @fopen($this->tpl_file'r'))) {
                        return 
'Error al abrir el Template <b>' $this->tpl_file"</b><br />";
                } else{
                        
$this->template_file fread($this->fdfilesize($this->tpl_file));
                        
fclose($this->fd);
                        
$this->mihtml $this->template_file;
                        
$this->mihtml str_replace ("'""\'"$this->mihtml);
                        
$this->mihtml preg_replace('#\{([a-z0-9\-_]*?)\}#is'"' . $\\1 . '"$this->mihtml);
                        
reset ($this->vars);
                        while (list(
$key$val) = each($this->vars)) {
                                $
$key $val;
                        }
                        eval(
"\$this->mihtml = '$this->mihtml';");
                        
reset ($this->vars);
                        while (list(
$key$val) = each($this->vars)) {
                                unset($
$key);
                        }
                        
$this->mihtml str_replace("\'""'"$this->mihtml);
                        
$this->mihtml str_replace(array("\r""\n"), ""$this->mihtml);
                        return 
$this->mihtml;
                }
        }
};
copialo dentro de una carpeta llamada include y lo llamas asi:
Código PHP:
include("template/template.class.php"); 
trabajas asi desde php
Código PHP:
      ////////////////////////////////////////////////////////
     ////////////// MUESTRO LA PAGINA
    ////////////////////////////////////////////////////////
    
$html = new Template("GxR/A.G.Main");
    
$html->vars(array(
        
"jsCAB"        =>    $Cab,
        
"MENU"     =>    $Data
    
));
    
$html->show(); 
y dentro de la carpeta templates debes estan tus html ej:
GxR/A.G.Main

Código HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Analisis de Fondos</title>
{jsCAB}
<link href="include/style.css" rel="stylesheet" type="text/css">
</head>
<body>
{MENU}
</body>
</html> 
esta es una forma existen varias maneras o framework q te ayudaran mucho,
__________________
~~[FiDeLio]~~