dongzaobei0942 2013-10-07 13:15
浏览 49
已采纳

其中一个PHP发布值不正确

I have a registration form for companies, with multiple fields. All but one are working fine... The one that isn't working was added later, and it always stores the same number, but I can't figure out why.

I've checked:

  • Default values in the MySQL database: nothing there.
  • Pulled the value of the input with JS from the console: it's the right field name and pulls the right value
  • Verified that there is only one field with that name: fine.
  • Looked for the number that gets stored in many included files: I can't find it.

The minute I submit the form, $_POST["empresa_cuit "] always carries the same number, which is unrelated to what I put in the input field.

Here's some of my code:

The 2 functions are:

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&eacute;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&oacute;digo de &aacute;rea v&aacute;lido (s&oacute;lo n&uacute;meros)."/>
                    <input type="text" name="empresa_tel" class="required digits"  value="<?php echo $empresa_txt['empresa_tel']; ?>" title="Debe ingresar un tel&eacute;fono v&aacute;lido (s&oacute;lo n&uacute;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']);

...

I've moved this line to the very top, so that I can monitor the value right away. The rest of the function is irrelevant after that, it ALWAYS shows the same number! The number has a phone number format, so I thought it might have been related to the phone fields (empresa_cod_tel and empresa_tel), but it doesn't matter what I put in there, the number in the CUIT field remains the same.

Could you help me troubleshoot this some more? I can't paste every related piece of code in here now, but let me know if you'd like to see anything else...

  • 写回答

3条回答 默认 最新

  • duandi8613 2013-10-07 13:27
    关注

    My only thought is this: if you are using a 32 bit integer and the phone number you are entering evaluates to greater than 2147483647, intval will always return 2147483647.

    I'd change it to store the phone number as a string.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起