PHP 表单大小截断
Posted
技术标签:
【中文标题】PHP 表单大小截断【英文标题】:PHP form size truncate 【发布时间】:2015-06-25 09:08:51 【问题描述】:我正在尝试通过form
保存数据。当我提交表单时,数据数为 45,但当我尝试获取我的 post 请求中的信息以保存它时,数字变为 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>
【问题讨论】:
什么? “数据数量”是什么意思? $user 数组的计数应该是 45 ?请更好地解释..... 是的,当您看到我的表单时,它有 45 行。但只保存了 39 行 $_POST['user'] 应该是一个有 45 个条目的数组?请张贴您的表格。 发帖请求的大小有限制吗? 【参考方案1】:是的,您提交的来自 45 行,每行有 27 个字段(1215 个值)。
您提交的字节数是否可能超过 php.ini 中的“post_max_size”值
尝试检查服务器上的 php.ini 并增加“post_max_size”的值。
链接:Increase Maximum PHP Upload Size
【讨论】:
以上是关于PHP 表单大小截断的主要内容,如果未能解决你的问题,请参考以下文章
php.ini修改 表单提交大小限制 和 文件上传大小限制配置
是否有可能增加 Flex 4 中火花标签截断提示的字体大小?
可以在上传之前在 html 表单上调整图像(客户端)的大小吗?