In this chapter we begin the design of the background management interface, this section mainly operates the Administrator module.
A Front-end new management
Html
<form id= "Manage_add" style= "margin:0;padding:5px 0 0
25px;color: #333; " >
<p> Admin Account: <input type= "text" name= "manager" class= "TextBox"
Style= "width:200px;" ></p>
<p> admin Password: <input type= "password" name= "password" class= "textbox"
Style= "width:200px;" ></p>
<p> Assigning permissions: <input id= "auth" class= "textbox" Name= "Auth"
Style= "WIDTH:205PX;" ></p>
</form>
New management pop-up window
$ (' #manage_add '). Dialog ({
WIDTH:350,
Title: ' New Management ',
Iconcls: ' Icon-user-add ',
Modal:true,
Closed:true,
Buttons: [
{
Text: ' Submit ',
Iconcls: ' Icon-add-new ',
Handler:function () {
if ($ (' #manage_add '). Form (' Validate ')) {
$.ajax ({
URL: ' addmanager.php ',
Type: ' POST ',
Data: {
Manager:
$.trim ($ (' input[name= "manager"]). Val ()),
Auth: $ (' #auth '). Combotree (' GetText '),
Password:
$.trim ($ (' input[name= ' password "] '). Val ()),
},
Beforesend:function () {
$.messager.progress ({
Text: ' Attempting to commit ... ',
});
},
Success:function (data, Response, status) {
$.messager.progress (' close ');
if (Data > 0) {
$.messager.show ({
title: ' Hint ',
msg: ' New management succeeded! ',
});
$ (' #manage_add '). Dialog (' Close '). Form (' Reset ');
$ (' #manage '). DataGrid (' reload ');
} else {
$.messager.alert (' Warning action ', ' unknown operation,
please resubmit! ', ' warning ');
}
}
});
}
},
},
{
Text: ' Cancel ',
Iconcls: ' Icon-redo ',
Handler:function () {
$ (' #manage_add '). Dialog (' Close '). Form (' Reset ');
},
}
],
});
//Manage account number
$ (' input[name= "manager"]). Validatebox ({
Required:true,
Validtype: ' length[2,20] ',
Missingmessage: ' Please enter a management name ',
Invalidmessage: ' Management name in 2-20 bits ',
});
//Manage Password
$ (' input[name= ' password "]). Validatebox ({
Required:true,
Validtype: ' length[6,30] ',
Missingmessage: ' Please enter admin password ',
invalidmessage: ' Manage password in 6-30 bit ',
} ';
//Assign Permissions
$ (' #auth '). Combotree ({
URL: ' nav.php ',
Required:true,
Lines:true,
Multiple:true,
Checkbox:true,
Onlyleafcheck:true,
Onloadsuccess:function (node, data) {
var _this = this;
if (data) {
$ (data). Each (function (index, value) {
if (this.state = = ' closed ') {
$ (_this). Tree (' ExpandAll ');
}
});
}
},
});
//Click add
Manage_tool = {
Add:function () {
$ (' #manage_add '). Dialog (' Open ');
$ (' input[name= "manager"]). focus ();
},
};
Two. Server-side new
//addmanager.php
<?php
require ' config.php ';
$manager = $_post[' manager '];
$auth = $_post[' auth ');
$password = SHA1 ($_post[' password ');
$date = time ();
mysql_query ("INSERT into Easyui_admin (manager,password,auth,date)
VALUES (' $manager ', ' $password ', ' $auth ', ' $date ') ') or Die (' SQL Error! ‘);
Echo Mysql_affected_rows ();
Mysql_close ();
?>
Admin Management interface-Administrator admin [2]