Create simple PHP & amp; MYSQL message board from classic

Source: Internet
Author: User

Table 1: admin
Field: id (int11) name (varchvr) password (varchvr)

Table 2: lo
Field: id (int11) username (varchvr) sex (varchvr) qq (varchvr) email (varchvr) info (text) ip (varchvr) submit_time (datetime)

1. conn. php (connect to the database file)
Copy codeThe Code is as follows:
<? Php
Mysql_connect ("localhost", "root", ""); // connect to the database
Mysql_select_db ("lyb"); // select a database
?>

2. header. php (Public header file)
Copy codeThe Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> Silver Message Board Version 1.0 </title>
</Head>
<Link href = "css.css" rel = "stylesheet" type = "text/css"/>
<Body>
<Div id = "head">
<Div id = "head_l">
<Ul>
<Li> <a href = "index. php"> Leave a message </a> </li>
<Li> <a href = "post. php"> occasionally published </a> </li>
<? Php
Session_start ();
If ($ _ SESSION ["key"] = 1) {// if the obtained SESSION is 1, the management item is displayed.
?>
<Li> <a href = "adminexit. php"> exit management </a> </li>
<?
}
Else
{
?>
<Li> <a href = "admin. php"> occasionally managed </a> </li>
<?}?>
</Ul>
</Div>
<Div id = "head_r"> Silver Message Board Version 1.0 </div>
</Div>

3. footer. php (Public bottom file)
Copy codeThe Code is as follows:
<? Php
$ CounterFile = "conter. xml ";
Function displayCounter ($ counterFile ){
$ Fp = fopen ($ counterFile, "rw ");
$ Num = fgets ($ fp, 5 );
$ Num + = 1;
Print "<div id = \" footer \ "> Silver Message Board Version 1.0". "$ num". "bored silver </div> ";
Exec ("rm-rf $ counterFile ");
Exec ("echo $ num> $ counterFile ");
}
If (! File_exists ($ counterFile )){
Exec ("echo 0> $ counterFile ");
}
DisplayCounter ($ counterFile );
?>

</Body>
</Html>

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.