PHP development corporate website tutorial modification administrator
We have seen the display page, modified, and linked to the modifu.php page
Let’s look at the code of the following page:
<?php
require_once('conn.php');
$id = $_GET['id'];
$sql = "SELECT * FROM user where id='$id'";
$info = mysql_query($sql);
$row = mysql_fetch_array($info);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>修改管理员</title>
<style type="text/css">
.ipt{width:180px;height:30px;border-radius:5px;outline:none;border:1px solid #eee;box-sizing:border-box;padding-left:15px;}
.sub{width:50px;height:20px;border:1px solid #eee;background:#eee;color:#ff7575;}
</style>
</head>
<body>
<form method="post" action="modifyuser.php?id=<?php echo $id;?>">
用户名:<input type="username" name="username" class="ipt" value="<?php echo $row['username'];?>">
</br></br>
密 码:<input type="password" name="password" class="ipt" value="<?php echo $row['password'];?>">
</br></br>
<input type="submit" value="修改" class="sub">
</form>
</body>
</html>Connect to the database
Then Get the id mentioned over there and query based on the id, save the database information to the page, so that we can delete the information and make modifications
Processing the modified php file modifyuser.php We also have a Parameter id
Let’s look at the code of the following modifyuser.php page:
<?php
//修改页面php代码
require_once('conn.php');
$name = $_POST['username'];
$password = md5($_POST['password']);
$id = $_GET['id'];
$sql = "UPDATE user SET username='$name',password='$password' where id='$id'";
$res = mysql_query($sql);
if($res){
echo "<script>alert('修改管理员成功');location.href='user.php'</script>";
}else{
echo "<script>alert('修改管理员失败');history.go(-1);</script>";
}
?>With the above code, we have completed the function of modifying the administrator
new file
<?php
require_once('conn.php');
$id = $_GET['id'];
$sql = "SELECT * FROM user where id='$id'";
$info = mysql_query($sql);
$row = mysql_fetch_array($info);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>修改管理员</title>
<style type="text/css">
.ipt{width:180px;height:30px;border-radius:5px;outline:none;border:1px solid #eee;box-sizing:border-box;padding-left:15px;}
.sub{width:50px;height:20px;border:1px solid #eee;background:#eee;color:#ff7575;}
</style>
</head>
<body>
<form method="post" action="modifyuser.php?id=<?php echo $id;?>">
用户名:<input type="username" name="username" class="ipt" value="<?php echo $row['username'];?>">
</br></br>
密 码:<input type="password" name="password" class="ipt" value="<?php echo $row['password'];?>">
</br></br>
<input type="submit" value="修改" class="sub">
</form>
</body>
</html>
Preview
Clear
- Course Recommendations
- Courseware download
The courseware is not available for download at the moment. The staff is currently organizing it. Please pay more attention to this course in the future~
Students who have watched this course are also learning
Let's briefly talk about starting a business in PHP
Quick introduction to web front-end development
Large-scale practical Tianlongbabu development of Mini version MVC framework imitating the encyclopedia website of embarrassing things
Getting Started with PHP Practical Development: PHP Quick Creation [Small Business Forum]
Login verification and classic message board
Computer network knowledge collection
Quick Start Node.JS Full Version
The front-end course that understands you best: HTML5/CSS3/ES6/NPM/Vue/...[Original]
Write your own PHP MVC framework (40 chapters in depth/big details/must read for newbies to advance)
















