Php: getting started with php-PHP source code

Source: Internet
Author: User
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



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.