Ec (2); & lt ;! DOCTYPEhtmlPUBLIC & quot;-W3CDTDXHTML1.0TransitionalEN & quot; www.111cn. netTRxhtml1DTDxhtml1-transitional.dtd & quot; & gt; & lt; htmlxmlns & quot; www.w3.org script ec (2); script
Add data to mysql in the php tutorial.
If ($ _ POST)
{
Mysql_connect ('localhost', 'root', 'root ');
Mysql_select_db ('fangke _ CC ');
Mysql_query ("set names 'gbk '");
$ Title = htmlspecialchars (isset ($ _ POST ['title'])? $ _ POST ['title']: '');
$ Keyword = htmlspecialchars (isset ($ _ POST ['keyword'])? $ _ POST ['keyword']: '');
$ Desc = htmlspecialchars (isset ($ _ POST ['desc'])? $ _ POST ['desc']: '');
$ Body = htmlspecialchars (isset ($ _ POST ['body'])? $ _ POST ['body']: '');
If ($ title = "" | strlen ($ title)> 200)
{
Exit ('script alert ("invalid title, re-enter information"); history. back (); script ');
}
Else if ($ body = "" | strlen ($ body)> 2048)
{
Exit ('script alert ("empty too long, re-enter the information"); history. back (); script ');
}
Else
{
$ Time = time ();
$ Body = preg_replace ("/$ title/", "". $ title. "", $ body, 1 );
$ SQL = "insert into su_zt (title, description, keyword, body, datetimes) values ('$ title',' $ desc', '$ keyword',' $ body ', '$ Time ')";
Mysql_query ($ SQL) or die (mysql_error (). $ SQL );
Die ('script alert ("saved successfully"); location = "'. $ _ SERVER ['HTTP _ referer'].'"; script ');
}
}
?>
Su_zt table structure
Create table if not exists 'su _ zt '(
'Id' int (8) not null auto_increment,
'Title' varchar (200) character set gb2312 default NULL,
'Keyword' varchar (60) character set gb2312 default NULL,
'Description' text character set gb2312,
'Body' text character set gb2312,
'Datetimes 'int (4) default NULL,
Primary key ('id ')
) ENGINE = MyISAM default charset = utf8 AUTO_INCREMENT = 2;
This site original tutorial, reprinted with the source of http://www.111cn.net, otherwise it is necessary to study