PHP development corporate website tutorial - adding administrators
In the previous section we have taken out the information from the database and displayed the display page
As you can see from the code in the previous section, we click to add an administrator and submit it to the addu.php page
Let’s take a look at the code of this page
添加管理员
Looking at the above code, we can see that the form is submitted to the adduser.php file in the form of post
Let’s do this Take a look at the code of the adduser.php file, and then analyze the code:
alert('管理员已存在');location.href='addu.php';"; }else{ $sql = "insert into `user`(username,password) values('$name','$password')"; $res = mysql_query($sql); if($res){ echo ""; }else{ echo ""; } } ?>
First we also need to connect to the database, and then receive the information submitted by the form
After that we need to judge the form submission Does the user exist? If it exists, a prompt will be given. If it does not exist, you can add it
As shown in the above code, in this way we have completed the function added by the administrator