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 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制