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é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']);
...
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...