PHP:隐藏字段的POST数据错误 [英] PHP: POST data of hidden fields error

查看:108
本文介绍了PHP:隐藏字段的POST数据错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试将某些隐藏字段以表格的形式从一页传递到另一页:

I'm trying to pass on some hidden fields in a form from one page to another:

<form action=\"secondPage.php\" method=\"post\">
   <input name=\"from\" type=\"hidden\" value=\"$fday/$fmonth/$fyear\">
   <input name=\"to\" type=\"hidden\" value=\"$tday/$tmonth/$tyear\">
   <input type=\"submit\">
</form>

secondPage.php包含:

secondPage.php contains:

<?php
   $fdate = $_POST("from");
   $tdate = $_POST("to");
   echo "$fdate --- $tdate";
?>

当我单击提交并重定向到secondPage.php时,出现此错误:

I get this error on when I click submit and am redirected to secondPage.php:

Fatal error: Array callback has to contain indices 0 and 1 in C:\xampp\htdocs\blah\secondPage.php on line 2

推荐答案

PHP使用方括号而不是括号来访问数组:

PHP uses square brackets rather than parentheses for accessing arrays:

<?php

    $fdate = $_POST["from"];
    $tdate = $_POST["to"];
    echo "$fdate --- $tdate";

?>

这篇关于PHP:隐藏字段的POST数据错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆