【问题标题】:Php $_Post doesn't work after certain length imputPhp $_Post 在输入一定长度后不起作用
【发布时间】:2017-07-16 01:54:36
【问题描述】:

我有一个表格

<form action="welcome.php" method="post" ........................">

      <button id=......................ERATE NEW ....</button>
      <br/><br/>
      <div class="form-field">
        <label for...............">....... TEST</label>
        <br/>
        <textarea id=...........................="false"></textarea>
        <span class="clipSp............ successfully copied to clipboard" ></span>
        <br/>
      </div>
      <br/>

      <div clas..........content">
        <div>ADDRESS
          <br/>
          <span>{{vm.displayAddress}}</span>
        </div>
      </div>
      <button class="wButton fade" type="submit">REGISTER ACCOUNT</button>
      <span class="divider-2"></span>
      <button class="wButton fade" type="reset" ng-click="vm.back()">BACK</button>
      .
      .
      .
      .

然后我有这个“welcome.php”文件。

if(!empty($_POST['formdesiredpost'])){
    $var  = $_POST['formdesiredpost'];
    file_put_contents("dat‌​a.txt", $var . "\n", FILE_APPEND); 
    header("Location: https://randomwebsiteredirect.com"); 
    exit();
}

它应该将所需值从表单 (textarea) 发布到一个 txt 文件 data.txt 然后重定向到一个网站。
问题是它仅适用于短长度输入。我的意思是 aprox (15 characters) ,如果我输入超过 15 , like 70, 它只是重定向到空白的welcome.php 并且什么也不做。

对可能发生的事情有任何线索吗?

【问题讨论】:

    标签: php html forms post


    【解决方案1】:

    在您的 html 中,您没有“formdesiredpost”字段。请检查是否存在“formdesiredpost”字段。

    在你的welcome.php中,在你的代码顶部添加错误报告功能:

    error_reporting(0);

    查看发送数据到welcome.php后发生了什么

    工作正常:

    index.php:

    <form action="welcome.php" method="post">
    <textarea name="formdesiredpost"></textarea>
    <input type="submit" value="submit">
    </form>
    

    欢迎.php

    <?php
    if(!empty($_POST['formdesiredpost'])){
        $var  = $_POST['formdesiredpost'];
        file_put_contents("data.txt", $var . "\n", FILE_APPEND); 
        header("Location: https://randomwebsiteredirect.com"); 
        exit();
    }
    ?>
    

    请检查您的字段字符限制:
    Limit number of characters allowed in form input text field

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-08-06
      • 2013-08-08
      • 2012-10-16
      • 1970-01-01
      • 2013-10-17
      • 2011-07-05
      • 2012-04-27
      相关资源
      最近更新 更多