download1214 2015-07-09 08:23
浏览 49
已采纳

使用导出按钮功能到另一个php文件

This is the form.php file and i would like to put export button file to another php file. I am still rocky for php language.

form php

<form action="<?php echo url_for("attendance/viewAttendanceRecord"); ?>" id="reportForm" method="post" name="frmAttendanceReport">
        <fieldset>
            <ol>
                <?php
                if ($form->hasErrors()) {
                    echo $form['employeeName']->renderError();
                }
                ?>
                <?php echo $form->render(); ?>
                <?php echo $form->renderHiddenFields(); ?>                

                <li class="required">
                    <em>*</em> <?php echo __(CommonMessages::REQUIRED_FIELD); ?>
                </li>
            </ol>
            <p class="formbuttons">
        <input type="button" class="" id="btExport" onclick='myfunction()' value="<?php echo __('Export') ?>"/>

I want to use export function in this action.php file

action.php

if($post['export'] == '1')
{
  //statement
}
  • 写回答

1条回答 默认 最新

  • dongxiequ3724 2015-07-09 10:45
    关注

    Php uses name attribute of the elements in order to build $_POST array. So add name attribute to button along with other input elements as follows.

    <input type="submit" id="btExport" name="btExport" value="<?php echo __('Export') ?>"/>
    

    in action.php do something like the following to handle posted values.

    if($_POST["btExport"])
    {
      //statement
    }
    

    or you can also check if $_POST is empty or not as follows

    if (!empty($_POST))
    {
      //statement
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 对于这个问题的解释说明
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。