PHP 表单大小截断

标签 php mysql forms save http-post

我正在尝试通过表单保存数据。当我提交表单时,数据数量是 45,但是当我尝试获取发布请求中的信息来保存它时,数据数量变成了 39,我不知道为什么。

有人有想法吗?

这是我用来在数据库中保存日期的代码:

    $config = new JConfig();

$mysqli = mysqli_connect($config->host, $config->user, $config->password, $config->db); 

$users = $_POST['user'];

foreach($users as $id => $user){

    $query ="UPDATE `expo_comprofiler` SET `cb_website`='".mysqli_real_escape_string($mysqli, $user[cb_website])."',
                                           `cb_rue`='".mysqli_real_escape_string($mysqli, $user[cb_rue])."',
                                           `cb_lieu`='".mysqli_real_escape_string($mysqli, $user[cb_lieu])."',
                                           `cb_domaine`='".mysqli_real_escape_string($mysqli, $user[cb_domaine])."',
                                           `cb_contact`='".mysqli_real_escape_string($mysqli, $user[cb_contact])."',
                                           `cb_description`='".mysqli_real_escape_string($mysqli, $user[cb_description])."',
                                           `cb_tlphonefixe`='".mysqli_real_escape_string($mysqli, $user[cb_tlphonefixe])."',
                                           `cb_tlphoneportable`='".mysqli_real_escape_string($mysqli, $user[cb_tlphoneportable])."',
                                           `cb_emplacementespr`='".mysqli_real_escape_string($mysqli, $user[cb_emplacementespr])."',
                                           `cb_standmodulable`='".mysqli_real_escape_string($mysqli, $user[cb_standmodulable])."',
                                           `cb_largeurstand`='".mysqli_real_escape_string($mysqli, $user[cb_largeurstand])."',
                                           `cb_longueurstand`='".mysqli_real_escape_string($mysqli, $user[cb_longueurstand])."',
                                           `cb_hauteurstand`='".mysqli_real_escape_string($mysqli, $user[cb_hauteurstand])."',
                                           `cb_remarques`='".mysqli_real_escape_string($mysqli, $user[cb_remarques])."',
                                           `cb_prise220v`='".mysqli_real_escape_string($mysqli, $user[cb_prise220v])."',
                                           `cb_prise380v`='".mysqli_real_escape_string($mysqli, $user[cb_prise380v])."',
                                           `cb_table`='".mysqli_real_escape_string($mysqli, $user[cb_table])."',
                                           `cb_bandeau`='".mysqli_real_escape_string($mysqli, $user[cb_bandeau])."',
                                           `cb_affiches`='".mysqli_real_escape_string($mysqli, $user[cb_affiches])."',
                                           `cb_publicite`='".mysqli_real_escape_string($mysqli, $user[cb_publicite])."',
                                           `cb_no_stand`='".mysqli_real_escape_string($mysqli, $user[cb_no_stand])."',
                                           `cb_surface_m2`='".mysqli_real_escape_string($mysqli, $user[cb_surface_m2])."',
                                           `cb_personnesinscrites`='".mysqli_real_escape_string($mysqli, $user[cb_personnesinscrites])."'
                WHERE `user_id`= ".$id;

    ?>
        <p><?php echo $query ?> </p>
        <?php

    if(!mysqli_query($mysqli, $query)){
        printf("Erreur : %s\n", mysqli_sqlstate($mysqli));
    }


    $queryUser = "UPDATE `expo_users` SET `name`='".mysqli_real_escape_string($mysqli, $user[name])."',
                                          `username`='".mysqli_real_escape_string($mysqli, $user[username])."',
                                          `email`='".mysqli_real_escape_string($mysqli, $user[email])."'
                  WHERE `id`= ".$id;
    if(!mysqli_query($mysqli, $queryUser)){
        printf("Erreur : %s\n", mysqli_sqlstate($mysqli));
    }

}

这是表格:

<form action="usersSave.php" id="formCommercants" method="post">
                    <table class="table table-hover table-condensed"> 
                        <thead>
                            <tr>
                                <th><?php echo "N° Stand"; ?></th>
                                <th><?php echo "Société"; ?></th>
                                <th><?php echo "Rue et numéro"; ?></th>
                                <th><?php echo "NPA et lieu"; ?></th>
                                <th><?php echo "Téléphone fixe"; ?></th>
                                <th><?php echo "Téléphone portable"; ?></th>
                                <th><?php echo "Adresse de courriel"; ?></th>
                                <th><?php echo "Site Internet"; ?></th>
                                <th><?php echo "Domaine d'activité"; ?></th>
                                <th><?php echo "Description"; ?></th>
                                <th><?php echo "Personne de contact"; ?></th>
                                <th><?php echo "Identifiant"; ?></th>
                                <th><?php echo "Emplacement espéré"; ?></th>
                                <th><?php echo "Stand modulable"; ?></th>
                                <th><?php echo "Largeur du stand"; ?></th>
                                <th><?php echo "Longueur du stand"; ?></th>
                                <th><?php echo "Hauteur du stand"; ?></th>
                                <th><?php echo "Surface m2"; ?></th>
                                <th><?php echo "Remarques"; ?></th>
                                <th><?php echo "Nombre prise 220V"; ?></th>
                                <th><?php echo "Nombre prise 380V"; ?></th>
                                <th><?php echo "Table"; ?></th>
                                <th><?php echo "Bandeau"; ?></th>
                                <th><?php echo "Affiches"; ?></th>
                                <th><?php echo "Publicité"; ?></th>
                                <th><?php echo "Personnes inscrites"; ?></th>
                                <th><?php echo "Année"; ?></th>
                            </tr>
                        </thead>

                        <tbody>
                        <?php 

                            $mysqli = mysqli_connect($config->host, $config->user, $config->password, $config->db); 

                            $query = "SELECT u.id,
                                            u.name,
                                            u.username,
                                            u.email,
                                            cb.cb_rue,
                                            cb.cb_lieu,
                                            cb.cb_tlphonefixe,
                                            cb.cb_tlphoneportable,
                                            cb.cb_website,
                                            cb.cb_domaine,
                                            cb.cb_description,
                                            cb.cb_contact,
                                            cb.cb_emplacementespr,
                                            cb.cb_standmodulable,
                                            cb.cb_largeurstand,
                                            cb.cb_longueurstand,
                                            cb.cb_hauteurstand,
                                            cb.cb_remarques,
                                            cb.cb_prise220v,
                                            cb.cb_prise380v,
                                            cb.cb_table,
                                            cb.cb_bandeau,
                                            cb.cb_affiches,
                                            cb.cb_publicite,
                                            cb.cb_personnesinscrites,
                                            cb.cb_annee,
                                            cb.cb_no_stand,
                                            cb.cb_surface_m2
                                     FROM expo_users u 
                                        INNER JOIN expo_comprofiler cb ON u.id = cb.user_id
                                        INNER JOIN expo_user_usergroup_map uum ON u.id = uum.user_id
                                     WHERE uum.group_id = 2 and cb.cb_annee = ". $year
                                     ." ORDER BY u.name";

                            $res = mysqli_query($mysqli, $query);
                            while($row = mysqli_fetch_object($res)){
                        ?>
                                <tr>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][cb_no_stand]" class="input-medium" value="<?php echo $row->cb_no_stand; ?>" required/> </td>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][name]" class="input-medium" value="<?php echo $row->name; ?>" required/> </td>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][cb_rue]" class="input-medium" value="<?php echo $row->cb_rue; ?>"/> </td>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][cb_lieu]" class="input-medium" value="<?php echo $row->cb_lieu; ?>"/> </td>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][cb_tlphonefixe]" class="input-medium" value="<?php echo $row->cb_tlphonefixe; ?>"/> </td>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][cb_tlphoneportable]" class="input-medium" value="<?php echo $row->cb_tlphoneportable; ?>"/> </td>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][email]" class="input-medium" value="<?php echo $row->email; ?>" required/> </td>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][cb_website]" class="input-medium" value="<?php echo $row->cb_website; ?>"/> </td>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][cb_domaine]" class="input-medium" value="<?php echo $row->cb_domaine; ?>"/> </td>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][cb_description]" class="input-medium" value="<?php echo $row->cb_description; ?>"/> </td>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][cb_contact]" class="input-medium" value="<?php echo $row->cb_contact; ?>"/> </td>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][username]" class="input-medium" value="<?php echo $row->username; ?>" required/> </td>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][cb_emplacementespr]" class="input-medium" value="<?php echo $row->cb_emplacementespr; ?>"/> </td>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][cb_standmodulable]" class="input-medium" value="<?php echo $row->cb_standmodulable; ?>"/> </td>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][cb_largeurstand]" class="input-medium" value="<?php echo $row->cb_largeurstand; ?>"/> </td>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][cb_longueurstand]" class="input-medium" value="<?php echo $row->cb_longueurstand; ?>"/> </td>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][cb_hauteurstand]" class="input-medium" value="<?php echo $row->cb_hauteurstand; ?>"/> </td>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][cb_surface_m2]" class="input-medium" value="<?php echo $row->cb_surface_m2; ?>"/> </td>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][cb_remarques]" class="input-medium" value="<?php echo $row->cb_remarques; ?>"/> </td>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][cb_prise220v]" class="input-medium" value="<?php echo $row->cb_prise220v; ?>"/> </td>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][cb_prise380v]" class="input-medium" value="<?php echo $row->cb_prise380v; ?>"/> </td>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][cb_table]" class="input-medium" value="<?php echo $row->cb_table; ?>"/> </td>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][cb_bandeau]" class="input-medium" value="<?php echo $row->cb_bandeau; ?>"/> </td>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][cb_affiches]" class="input-medium" value="<?php echo $row->cb_affiches; ?>"/> </td>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][cb_publicite]" class="input-medium" value="<?php echo $row->cb_publicite; ?>"/> </td>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][cb_personnesinscrites]" class="input-medium" value="<?php echo $row->cb_personnesinscrites; ?>"/> </td>
                                    <td><input type="text" name="user[<?php echo $row->id; ?>][cb_annee]" class="input-medium" disabled value="<?php echo $row->cb_annee; ?>"/> </td>
                                </tr>
                        <?php
                            }

                        ?>
                        </tbody>
                    </table>
                </form>

最佳答案

是的,您提交的表单有 45 行,每行有 27 个字段(1215 个值)。

您提交的字节数是否可能超过 php.ini 中的“post_max_size”值

尝试检查服务器上的 php.ini 并增加“post_max_size”的值。

链接:Increase Maximum PHP Upload Size

关于PHP 表单大小截断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31045912/

相关文章:

php - 仅当满足 php 条件时才运行 javascript 函数

php - Yii HAS_MANY 与非外键和非主键的关系

php - 删除按钮未返回删除查询的正确值

mysql - 在逗号上拆分不平衡的 GEO 字符串

具有不区分大小写选择和唯一索引的 MySQL 表

php - 如何使用 PHP、MySQL 和 Jquery 创建测验

asp.net-mvc - ASP.NET MVC 表单重新填充

php - 最佳 OOP 实践 PHP/MySQL

javascript - 需要使用 javascript trim 表单中的所有元素

php - 一个查询而不是多个查询