Ec (2); & lt ;? Php Data Structure CREATETABLEIFNOTEXISTS 'Leo _ user' (& nbsp; 'id' int (11) NOTNULLAUTO_INCREMENT, & nbsp; 'name' char (30) NOTNULL, & nbsp; 'birthday' dateNOTNULL, & nbsp; 'email 'char (60) script ec (2); script
Data Structure
Create table if not exists 'Leo _ user '(
'Id' int (11) not null AUTO_INCREMENT,
'Name' char (30) not null,
'Birthday' date not null,
'Email 'char (60) not null,
'Sex' enum ('M', 'F', '-') not null,
Primary key ('id '),
Unique key 'email '('email ')
) ENGINE = MyISAM default charset = utf8 AUTO_INCREMENT = 5;
--
-- Export the table data 'Leo _ user'
--
Insert into 'Leo _ user' ('id', 'name', 'birthday', 'email ', 'sex') VALUES
(1, 'zhang san', '2017-01-01 ', 'zhangshan @ email.com', 'M '),
(2, 'Li si', '2017-01-25 ', 'lisi @ test.com', 'M '),
(3, 'wang 5', '2017-12-24 ', 'wangwu @ leophp1.cn ','-'),
(4, 'zhao liu', '2017-05-05 ', 'zhaoliu @ test.com', 'F ');
Function db_exec ($ SQL ){
$ Resource = mysql tutorial _ connect (DB_HOST, DB_USER, DB_PASSWORD); // Connection database tutorial
Mysql_query ("set names '". DB_CHARSET. "';"); // SET the font SET
$ Connect = mysql_select_db (DB_NAME, $ resource); // select a database
Return mysql_query ($ SQL, $ resource); // Execute SQL
}
If ($ _ POST ['op'] = 'add '){
$ SQL ="
Insert into ". TABLE_PREFIX." user (
Name,
Birthday,
Email,
Sex)
VALUES (
'". $ _ POST ['name']."',
'". $ _ POST ['birthday']."',
'". $ _ POST ['email']." ',
'". $ _ POST ['sex']."'
)";
If (db_exec ($ SQL )){
$ Notice = array (
'Msg '=> 'added successfully ',
'Alt' => 'list Users ',
'Url' => '? Op = Index'
);
Require_once www.111cn.net/_notice.phtml ';
} Else {
$ Notice = array (
'Msg '=> 'add failed ',
'Alt' => 'add user ',
'Url' => '? Op = add'
);
Require_once www.111cn.net/_notice.phtml ';
}
} Else {
Require_once 'view/add. phtml ';
}
// Add. phtml template page
Add User
Add User