1

我需要帮助来解决完全阻止我的项目的打印问题。准确地说,我有两篇包含 PHP 代码的 Joomla 文章(我使用插件 Free sourcerer)。

第一篇文章包含以下代码:

{source}
  <form method="post" action="http://localhost/essai/index.php?option=com_content&view=article&id=2">
     <p>
         <input type="text" name="num" />
     </p>
   <input type="submit" value="Display the value of num" />
  </form>
{/source}

id 为 2 的第二篇文章包含以下代码:

{sourcer}
   if (isset ($_POST [ 'num'])) { 
       $Address=J Request :: getVar( 'num', '', 'post'); 
       echo $Address; 
   } else { 
       echo "num does not exist";
   }
{/source}

我的目标是恢复第二篇文章中 id 为 2 的表单 num 的输入字段的值并打印。当我点击“显示num的值”按钮时,值区num被检索并显示,但是当我点击链接打印文章时,在打开的窗口中显示“不存在num”。当我打印文章时,$ _POST ['num']不存在!

这是在 Joomla 或其他中打印的问题吗?请帮帮我。

注意:我使用 Joomla_2.5.9,模板 Beez2 集成在 joomla 中,Sourcerer-Free v4.1.3

4

1 回答 1

0

您需要进行 2 项更改才能使其正常工作。

1 - 我在 PHP 中包含了表单

{source}
<?php       
    echo'<form method="post" action="http://localhost/essai/index.php?option=com_content&view=article&id=2">' .
        '<p>' .
        '<input type="text" name="num" />' .
        '</p>' .
        '<input type="submit" value="Display the value of num" />' .
        '</form>';
?>
{/source}

2 - 从代码中删除一些额外的空格

{source}
<?php  
   if (isset($_POST['num'])) { 
       $Address=JRequest :: getVar('num','','post'); 
       echo $Address; 
   } else { 
       echo "num does not exist";
   }        
?>
{/source}
于 2013-03-28T11:11:36.653 回答