表格未张贴

时间:2011-11-20 13:18:24

标签: php forms

我正在尝试在PHP文件中创建HTML代码并从我的PHP代码返回。

<?php
require 'class.document.php';
error_reporting(0);

$usrdir=$_SESSION['username'];
$directory = "C:/xampp/htdocs/researchPortal/document_repository/".$usrdir."/";
$documents = glob("C:/xampp/htdocs/researchPortal/document_repository/student/{*.doc,*.docx,*.png}", GLOB_BRACE);
$docArray = array();


foreach($documents as $doc) {
    $document = new Document(time(),basename($doc),substr($doc, -3),substr((filesize($doc)/1024),0,6)." KB",date("F d Y H:i:s.",filectime($doc)),date("F d Y H:i:s.",filemtime($doc)));
    array_push($docArray,$document);
}


$html=  '<table class="data display datatable" id="example">
<thead>
<tr>
<th style="width:20px;">#</th>
<th>Document Name</th>
<th style="width:50px;">Type</th>
<th>Size</th>
<th>Date Created</th>
<th>Date Modified</th>
<th style="width:80px;">Action</th>
</tr>
</thead>
<tbody>';

$c=0;
foreach($docArray as $file) {

    if ($c%2) {
        $style='even';
    } else {
        $style='odd';
    }

    $con .=             '<tr class="'.$style.' gradeX">
<form id="view-doc" method="post" action="../classes/openDoc.php">
<input type="hidden" id="id" value="'.$c.'"/>
<input type="hidden" id="filename" value="'.$file->filename.'"/>
<input type="hidden" id="filetype" value="'.$file->filetype.'"/>
<td>'.$c.'</td>
<td>'.$file->filename.'</td>
<td>'.$file->filetype.'</td>
<td>'.$file->filesize.'</td>
<td>'.$file->datecreated.'</td>
<td>'.$file->datemodified.'</td>
<td><input type="submit" class="s-button btn_normal" id="submit" value="View" /></td>
</form>
</tr>';
    $c+=1;
}



echo $html.$con.'</tbody></table>';

?>

但表格尚未发布。我做错了什么?

编辑:openDoc.php

<?php

define("ZOHO_API_KEY", "");
$url = 'http://export.writer.zoho.com/remotedoc.im?apikey='.ZOHO_API_KEY.'&output=url';

$id=$_SESSION['id'];
$filename=$_SESSION['filename'];
$filetype=$_SESSION['filetype'];
$usrdir=$_SESSION['username'];


        $fields = array("
        'content' => '@/home/a5526551/public_html/document_repository/".$usrdir."/".$filename.",
        'apikey' => '',
        'output' => 'editor',
        'id' => ".$id.",
        'filename' => ".$filename.",
        'format' => ".$filetype.",
        'saveurl' => 'researchportal.host56.com/save.php',
        'mode' => 'normaledit'
          ");
        //echo getcwd();
        //echo curl('https://exportwriter.zoho.com/remotedoc.im',$fields);

        echo $fields["filename"];
?>

2 个答案:

答案 0 :(得分:3)

怎么没有发布?按钮不起作用还是不能在服务器端找到它?您还应为字段设置一些名称以便能够识别数据,即:

<input type="text" name="test" value="hello" />

要找到它,你会这样做:

<?php if($_POST['test']) echo $_POST['test']; ?>

答案 1 :(得分:1)

您的表单元素没有name属性。如果没有$_POST属性,则不会显示在name=中:

<input name='id' type="hidden" id="id" value="'.$c.'"/>
<input name='filename' type="hidden" id="filename" value="'.$file->filename.'"/>
<input name='filetype' type="hidden" id="filetype" value="'.$file->filetype.'"/>