Hi. I have this code: <?php global $fecha_trabajo; $fecha_trabajo = $_POST['fecha']; <--- receive value from form $tpl = new Plantilla(); $tpl->display('plantilla.tpl.php'); ?> PHP: In plantilla.tpl.php <!DOCTYPE html> <html lang="es"> <body> <form name="view" action="process.php" method="POST" enctype="multipart/form-data"> (.....) </form> </body> </html> HTML: In process.php: <?php echo $fecha_trabajo; <-- I trying to show this variable but.... ?> PHP: The system show me this message What is wrong? Can somebody help me?
I use this: <?php global $fecha_trabajo; $fecha_trabajo = $_POST['fecha']; <--- receive value from form $GLOBALS['fd'] = $fecha_trabajo; $tpl = new Plantilla(); $tpl->display('plantilla.tpl.php'); ?> PHP: And in the other php file called by Smarty template: <?php echo $GLOBALS['fd']; <-- I trying to show this variable but.... ?> PHP: But show me the same message.
The code should be like this: <?php $GLOBALS['fd'] = $_POST['fecha']; $tpl = new Plantilla(); $tpl->display('plantilla.tpl.php'); ?> PHP: <?php echo $fd; ?> PHP:
There is no reason for you to use globals as $_POST is global in itself, just do `echo $_POST['fecha']` in the template and it should work fine.
This is a better route to go than what you were previously doing. Be sure to read up on security and vulnerabilities for sessions