In php learning, it is good to open a message book as an entry material for php.
In php learning, it is good to open a message book as an entry material for php.
SQL required in the project:
The Code is as follows:
Create database form;
Use form;
Create table 'message '(
'Id' tinyint (1) not null auto_increment,
'User' varchar (25) not null,
'Title' varchar (50) not null,
'Content' tinytext not null,
'Lastdate' date not null,
Primary key ('id ')
) ENGINE = InnoDB default charset = gbk AUTO_INCREMENT = 1;
Conn. php
The Code is as follows:
$ Conn = @ mysql_connect ("localhost", "root", "") or die ("Database Link error ");
Mysql_select_db ("form", $ conn );
Mysql_query ("set names 'gbk '");
?>
Add. php
The Code is as follows:
Include 'conn. php ';
If ($ _ POST ['submit ']) {
$ SQL = "INSERT INTO message (id, user, title, content, lastdate) VALUES (NULL, '$ _ POST [user]', '$ _ POST [title]', '$ _ POST [content]', now ())";
Mysql_query ($ SQL );
// Page Jump, implemented in javascript
$ Url = "list. php ";
Echo"