我正在尝试通过一个简单的表单来更新用户级别,但它显示我未定义的索引,而不是更新级别,是否有人帮我这样做?
<h3>Update User Level</h3>
<form action="" method="POST">
UserID:<br/>
<input type="text" name="upduser" maxlength="30"> <br/>
Designation code:<br>
<?php
//require 'config.php';
$options = '';
$filter=mysql_query("select`user_dsgntn_code` from `hr_user`");
while($row = mysql_fetch_array($filter)) {
$options .="<option>" . $row['user_dsgntn_code'] . "</option>";
}
$dropdown="<form id='designation' name='designation' method='POST' action=''>
<select name='updlevel' onchange='showUser(this.value)'>
" . $options . "
</select>
</form>";
echo $dropdown;
//do_alert("$options");
?>
<br>
<input type="submit" value="Update Level">
</form>
<?
//require 'config.php';
if ( isset( $_POST['upduser'] ) && ! empty ( $_POST['upduser'] )&&
isset ($_POST['updlevel']));
{
$updtuser=$_POST['upduser'];
$updtlevel=$_POST['updlevel'];
$sql_upd="update `hr_user` set user_dsgntn_code='$updtlevel' WHERE user_id='$updtuser'";
$result = mysql_query($sql_upd) or die(mysql_error());
}
答案 0 :(得分:0)
删除<select>
附近的额外表单。
<h3>Update User Level</h3>
<form action="" method="POST">
UserID:<br/>
<input type="text" name="upduser" maxlength="30"> <br/>
Designation code:<br>
<?php
//require 'config.php';
$options = '';
$filter=mysql_query("select`user_dsgntn_code` from `hr_user`");
while($row = mysql_fetch_array($filter)) {
$options .="<option>" . $row['user_dsgntn_code'] . "</option>";
}
$dropdown="<select id='designation' name='updlevel' onchange='showUser(this.value)'>
" . $options . "
</select>";
echo $dropdown;
//do_alert("$options");
?>
<br>
<input type="submit" value="Update Level">
</form>