[英]One of the PHP posted values is not right
我有一個公司的注冊表,有多個領域。 除了一個之外的所有工作都很好......后來添加了一個不工作的,它總是存儲相同的數字,但我無法弄清楚原因。
我檢查過:
提交表單的那一刻, $_POST["empresa_cuit "]
總是帶有相同的數字,這與我在輸入字段中輸入的數字無關。
這是我的一些代碼:
這兩個功能是:
function defaultForm() {
global $url, $url_prefix, $user_prefix;
global $root;
global $selected;
global $id;
$empresa = get_empresa($id);
$empresa_txt = mysql_fetch_array($empresa);
?>
<form method="post" enctype="multipart/form-data" id='update_datos'>
<h2>Empresa <?php echo $empresa_txt['empresa']; ?></h2>
<div class="clearfix">
<label for="empresa">Nombre de la empresa</label>
<div class="input">
<input type="text" name="empresa" value="<?php echo $empresa_txt['empresa']; ?>" class="required" title="Este campo es obligatorio."/>
</div>
</div>
<div class="clearfix">
<label for="empresa_cuit">CUIT</label>
<div class="input">
<input type="text" name="empresa_cuit" id="empresa_cuit" class="required digits" minlength="11" maxlength="11" title="Ingrese los 11 dígitos del CUIT, sin guiones." value="<?php //echo $empresa_txt['empresa_cuit'];?>"/>
<br /><span class="aclaracion">Ingrese sólo números.</span>
</div>
</div>
<div class="clearfix">
<label for="empresa_tel">Teléfono</label>
<div class="input">
<input type="text" name="empresa_cod_tel" id="empresa_cod_tel" maxlength="6" size="6" class="required digits areacode" value="<?php echo $empresa_txt['empresa_cod_tel']; ?>" title="Debe ingresar un código de área válido (sólo números)."/>
<input type="text" name="empresa_tel" class="required digits" value="<?php echo $empresa_txt['empresa_tel']; ?>" title="Debe ingresar un teléfono válido (sólo números)."/>
</div>
</div>
<input name="Submit" type="submit" value="Actualizar" class='white button'/>
<input name="filter" type="hidden" value="processForm">
<!-- hidden value points the switch to processing -->
</form>
<?php return; } #/ End of defaultForm ?>
-
function processForm() {
echo $empresa_cuit = intval($_POST['empresa_cuit']);
...
我已將此行移至最頂層,以便我可以立即監控該值。 其余的功能是無關緊要的,它始終顯示相同的數字! 這個號碼有一個電話號碼格式,所以我認為它可能與電話字段(empresa_cod_tel和empresa_tel)有關,但是我放在那里並不重要,CUIT字段中的數字保持不變。
你能幫我解決這個問題嗎? 我現在不能在這里粘貼所有相關的代碼,但如果你想看到別的東西,請告訴我。
我唯一想到的是:如果您使用的是32位整數,並且您輸入的電話號碼的評估值大於2147483647,則intval將始終返回2147483647。
我將其更改為將電話號碼存儲為字符串。
我認為你在DB int列,將其更改為varchar,問題將得到修復。
我繼續這里的主題,而不是在評論中,因為我們可能會有所作為。
所以如果你寫$ _POST ['empresa_cuit']你會看到正確的值嗎?
有什么價值? 可以在那里使任何字符使intval無法解析它 - 在這種情況下intval返回0。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.