Hi, I have several hours trying to debug this problem:
I have a html form that is for edit existing data, this form has 3 fields, then when the user press the submit button the update.php script is called, but the problem is: only 2 of the 3 fields are passed with data, the last textfield -bugtxt- is submitted to the php script empty, really I don't know why, I've already restart the apache server but still the problem is there.
Here is the edit.php code:
<table align="center" border="2">
<TR>
<TD colspan="2" align="center">EDITAR INFORMACION DEL USUARIO</TD>
</TR>
<TR><TD>Nombre del Usuario</TD><TD><INPUT type='text' size='25' maxlength='60' name='txtnomusu' value='<?php echo $xnombres ?>'></TD></TR>;
<TR>
<TD>Contraseña</TD><TD><INPUT type='password' size='15' maxlength='15' name='txtclausu'></TD>
</TR>
<TR>
<TD>Permiso de usuario</TD><TD><INPUT type='text' size='1' maxlength='1' name 'bugtxt'
value='<?php echo $xnivel ?>'></TD>
</TR>
<tr><TD colspan="2"> </TD></tr>
<TR align="center"><TD colspan="2"><INPUT type="submit" name="btnenviar" value="Grabar"> <INPUT type="submit" name="btnenviar" value="Cancelar"></TD>
</TR>
</table>
Then, it update.php, the value submitted by "bugtxt" is alwasys empty, the other fields have data.
<?php
session_start();
if (@$_SESSION['auth'] !="yes")
{
header("Location: nologin.php");
exit();
}
else{
include("vars.php");
if($_POST['btnenviar']=="Cancelar"){
header('Location: irrhh.php');
}
else{
$ynuecla=md5($_POST['txtclausu']);
$ynomusu=$_POST['txtnomusu'];
$ynivusu= $_POST['bugtxt'];
$znivusu=(int)$ynivusu;
$_SESSION['x']=$ynivusu;
$conn=mysqli_connect($host, $user, $password) or die("No se pudo establecer comunicacion");
$db=mysqli_select_db($conn, $basedatos) or die("Error en la base de datos");
$sql="UPDATE $tabla0 SET clausu='$ynuecla', nomusu='$ynomusu', nivusu='$znivusu' WHERE id='". $_SESSION[ 'xusuarioid' ]. "'";
mysqli_query($conn, $sql) or die(mysqli_error($conn));
header('Location: irrhh.php');
}
}
?>
Trying to isolate the problem, I think that in the submit event is the problem, but I don't get it because in edit.php I think is all ok, also, update.php receive just 2 data instead of 3.
Any suggestions are welcome
Regards