dte49889 2013-10-17 10:00
浏览 25
已采纳

数组没有发布到php

HTML

<link rel="stylesheet" type="text/css" href="<?php echo CSS_URL ?>modal.css" /> 
   <form id="postinfo" action="" method="POST">
    <input type="hidden" name="technician" value="<?php echo $technician; ?>">
       <input type="hidden" name="custnum" value="<?php echo    htmlentities(serialize($customerNum)); ?>">
       <input type="hidden" name="meternum" value="<?php echo htmlentities(serialize($meterNumbers)); ?>">
       <input type="hidden" name="remcred" value="<?php echo htmlentities(serialize($remCreditArray)); ?>">
       <input type="hidden" name="visitdate" value="<?php echo htmlentities(serialize($dateArray)); ?>">
        <a href ="<?php echo PROCESS_URL; ?>create_maint_token_excel.php" onclick="document.getElementById('postinfo').submit();">
                <img src="<?php echo IMAGE_URL ?>Excel.png" name="Print Excel" title="Print Excel" alt="Print Excel" /></a>

   </form>

PHP

$customerNum = unserialize($_POST['custnum']);
$meterNumbers = unserialize($_POST['meternum']);
$remCreditArray = unserialize($_POST['remcred']);
$dateArray = unserialize($_POST['visitdate']);
$technician = ($_POST['technician']); 

I have tried numerous ways of posting these arrays to a php page but the page keeps telling me that custnum, meternum, remcred and visitdate are undefined.

I have tried using a form action and post, I have tried to use a piece of javascript and I keep getting the same problem, why is this not posting?

I have also tried using $_GET instead of $_POST on php page to no avail.

  • 写回答

5条回答 默认 最新

  • dongzha2525 2013-10-17 10:10
    关注
    <a href ="<?php echo PROCESS_URL; ?>create_maint_token_excel.php" onclick="document.getElementById('postinfo').submit();">
    

    This will not work, the submit will go into nirvana and you will be taken to the PHP page without the variables. You are doing two requests at once and your browser will go to the one without the form variables.

    Try changing your form to this:

    <form id="postinfo" action="<?php echo PROCESS_URL; ?>create_maint_token_excel.php" method="POST">
    

    And your Link to this:

    <a href ="#" onclick="document.getElementById('postinfo').submit();">
    

    This should submit the form correctly without following the link.

    Alternatively use a propper <input type="submit" /> button, you can add the image to it with CSS.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 ensp路由器启动不了一直报#
  • ¥50 安卓10如何在没有root权限的情况下设置开机自动启动指定app?
  • ¥15 ats2837 spi2从机的代码
  • ¥200 wsl2 vllm qwen1.5部署问题
  • ¥100 有偿求数字经济对经贸的影响机制的一个数学模型,弄不出来已经快要碎掉了
  • ¥15 数学建模数学建模需要
  • ¥15 已知许多点位,想通过高斯分布来随机选择固定数量的点位怎么改
  • ¥20 nao机器人语音识别问题
  • ¥15 怎么生成确定数目的泊松点过程
  • ¥15 layui数据表格多次重载的数据覆盖问题