繁体   English   中英

通过URL将PHP变量传递给外部表单

[英]Pass PHP Variable to External Form via URL

我想知道是否有人可以帮助我。

我正在HTML表单中捕获Session variable ,如下所示:

$lid = $_SESSION['lid'];

然后,使用以下代码行从该主要HTML表单中,使用“ mysqlajaxtableeditor”软件加载外部ajax表:

</script> 
 <!-- Set ajax url -->
        <script type="text/javascript">
            trackHistory = false;
            var ajaxUrl = 'Example3.php';
        </script>

<body id="page2" onload="toAjaxTableEditor('update_html','');">

我想做的是从主表单中捕获Session variable ,并将其传递给外部ajax表。

我已经阅读了该站点上的许多帖子,希望可以解决我的问题,但是似乎无法传递其价值。

从我阅读的内容中,我已经尝试了以下主要形式: var ajaxUrl = 'Example3.php?lid=$lid'; ,然后在接收的AJAX表脚本中, $lid = $_GET['lid']; 但它不起作用,我不确定我要去哪里。

有关更多信息,我在下面发布了AJAX表代码:

class Example1 extends Common
{
    function initiateEditor()
   {
      $tableColumns['findid'] = array('display_text' => 'Find ID', 'perms' => 'TV');
      $tableColumns['dateoftrip'] = array('display_text' => 'Date of Trip', 'perms' => 'ETV');
      $tableColumns['finddescription'] = array('display_text' => 'Find Description', 'perms' => 'ETV');
      $tableColumns['detectorname'] = array('display_text' => 'Detector Used', 'perms' => 'EVT');
      $tableColumns['searchheadname'] = array('display_text' => 'Search Head Used', 'perms' => 'ETV');
      $tableColumns['pasref'] = array('display_text' => 'PAS Ref.', 'perms' => 'ETV');

      $tableName = 'finds';
      $primaryCol = 'findid';
      $errorFun = array(&$this,'logError');
      $permissions = 'EID';

      require_once('php/AjaxTableEditor.php');
      $this->Editor = new AjaxTableEditor($tableName,$primaryCol,$errorFun,$permissions,$tableColumns);
      $this->Editor->setConfig('tableInfo','cellpadding="1" width="800" class="mateTable"');
      $this->Editor->setConfig('tableTitle','');
      $this->Editor->setConfig('orderByColumn','dateoftrip');
      $this->Editor->setConfig('editRowTitle','Edit Details');
      $this->Editor->setConfig('iconTitle','Edit Find Details');
   }


   function Example1()
   {
      if(isset($_POST['json']))
      {
         session_start();
         $this->mysqlConnect();
         if(ini_get('magic_quotes_gpc'))
         {
            $_POST['json'] = stripslashes($_POST['json']);
         }
         if(function_exists('json_decode'))
         {
            $data = json_decode($_POST['json']);
         }
         else
         {
            require_once('php/JSON.php');
            $js = new Services_JSON();
            $data = $js->decode($_POST['json']);
         }
         if(empty($data->info) && strlen(trim($data->info)) == 0)
         {
            $data->info = '';
         }
         $this->initiateEditor();
         $this->Editor->main($data->action,$data->info);
         if(function_exists('json_encode'))
         {
            echo json_encode($this->Editor->retArr);
         }
         else
         {
            echo $js->encode($this->Editor->retArr);
         }

      }
   }
}
$lte = new Example1();
?>

我只是想知道是否有人可以看看这个,然后让我知道我要去哪里错了?

非常感谢和问候

经过大量工作并搜索了Internet,我找到了解决方案。

在HMTL页面中,我这样写:

 <!-- Set ajax url -->
        <script type="text/javascript">
            trackHistory = false;
            var ajaxUrl = 'ajaxtable.php?lid=$lid';
        </script>
<body id="page2" onload="toAjaxTableEditor('update_html','');">

在收到的AJAX表编辑器软件脚本中,我写了:

function initiateEditor()
{
    $tableColumns['locationid'] = array('display_text' => '', 'perms' => '','data_filters' => array('filters' => array("='".$_SESSION['lid']."'")), 'default' => $_SESSION['lid']);

我希望这对以后的人有所帮助。

亲切的问候

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM