代码拉取完成,页面将自动刷新
<!DOCTYPE html>
<?php
$frist=!count($_POST);
?>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
if($frist){
if($_GET["id"]){
$uid=(int)$_GET["id"];
//要求用户id必须是数字
if($uid){
$hostname="127.0.0.1";
$username="root";
$password="123456";
$database="myshop";
$connect=mysqli_connect($hostname, $username,
$password, $database);
//设置连接的字符集
mysqli_set_charset($connect, "utf-8");
if($connect){
$sqlstring="select * from userinfos where uid=${uid}";
$result=mysqli_query($connect, $sqlstring);
//mysqli_num_rows 获得查询结果集中有多少条数据
if( mysqli_num_rows($result)==0){
echo "参数错误";
}else{
$row= mysqli_fetch_array($result);
?>
<h1>添加用户</h1>
<form action="edituser.php" method="post" enctype="multipart/form-data">
账户:<input type="text" name="username" value="<?php echo $row["username"];?>"/><br/>
密码:<input type="password" name="upwd" value="<?php echo $row["upasswd"];?>"/><br/>
性别:<select name="sex">
<option <?php echo $row["sex"]=='男'?"selected=\"selected\"":"";?> >男</option>
<option <?php echo $row["sex"]=='女'?"selected=\"selected\"":"";?> >女</option>
</select>
<br/>
年龄:
<select name="age">
<?php
for($index=18;$index<=100;$index++){
if($index==$row["age"]){
echo "<option selected=\"selected\">$index</option>";
}else{
echo "<option>$index</option>";
}
}
?>
</select>
<br/>
原来头像:<img src="<?php echo $row["pic"];?>" style="height: 100px;width: 100px;" />
<br/>
更改头像:<input type="file" name="myimg"/><br/>
<input type="submit" value="确定"/>
<input type="reset" value="取消"/>
</form>
<?php
}
}
}else{
echo "参数错误";
}
}
?>
<?php
}
?>
</body>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。