May 26 Message Board Exercises

Source: Internet
Author: User

---restore content starts---

             Title: Department internal message Board

First, requirements:

The software is used as a message between employees in the department and send messages.

The system must be authenticated by password and logged into. The method is to verify the data from the user name and password in the database.

User management of the work (such as adding, deleting, modifying the user) through the direct implementation of the database operation, not implemented in the system, you can add test data in the database user table.

The system consists of four functions

1 Login: Verify user name and password, save session information, enter main interface.

2 exit: Exit the usage status, empty the session information, and return to the login screen.

3 Information Query: Displays the information that is left to the current login and the public information (sent to everyone).

4 messages: The current sign-in person is used to send information to other people's functions. The content of the information includes: the number of the information (automatic numbering), the sender, the content of the message, the recipient, the time of delivery, etc., can be issued to all, can also be issued to a person.

Second, the example page:

1 Login Interface

2 Main interface

3 Publishing Information interface

Format and requirements for database creation tables:

CREATE TABLE Yuangong
(
UserName varchar (primary key),
PassWord varchar (20),
Name varchar (20)
);
CREATE TABLE Firend
(
Ids int Auto_increment primary KEY,
Me varchar (20),
Firend varchar (20)
);
CREATE TABLE Liuyan
(
Ids int Auto_increment primary KEY,
Sender varchar (20),
Recever varchar (20),
Times datetime,
Comment text,
States bit
);

At the beginning of their own when the understanding of the main page is biased, previously shown that the entire Liuyan table content is now corrected only to show the login is the recipient of the information, and there is no drop-down list of the way to select the sender (because the list of data is not quite the same)

Login Data Display page: denglu.php

<! DOCTYPE html Public "-//w3c//dtd XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >nbsp; <a href= "denglu.php" ><input type= "reset" value= "reset" style= "width:100px"/></a> </td> &lt ;/tr></table></form></body>View Code

Login Data processing page: dengluchuli.php

<?PHPSession_Start();$username=$_post["Username"];$password=$_post["Password"];include(".. /dbda.php ");$db=NewDbda ();$sql= "SELECT count (*) from yuangong where UserName = ' {$username} ' and PassWord = ' {$password}‘";$attr=$db->query ($sql);if($attr[0] [0]==1]//Find the Data{    Header("location:main.php"); $_session["username"] =$username;}Else{    Echo"NO"; }
View Code

Main Page: is the recipient-oriented: main.php

<! DOCTYPE html Public"-//w3c//dtd XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >nbsp;<a href= "denglu.php" ><span> exit system </span></a></div><br/><br/>PHPSession_Start();if(Empty($_session["Username"])){    Header("location:denglu.php"); Exit;}include(".. /dbda.php "); $db=NewDbda ();$username=$_session["Username"];//echo $username;//lisi$sqln= "Select Name from yuangong where Username = ' {$username}‘";$attrn=$db->query ($sqln);$recever=$attrn[0] [0];//echo $recever;$sql= "SELECT * from Liuyan where recever = ' {$recever} ' or recever = ' everyone ' "; $attr=$db->query ($sql);//Var_dump ($attr);foreach($attr  as $v){            Echo"<tr height= ' 50px ' align= ' center ' > <td>{$v[1]}</td> <td>{$v[3]}</td> <td>{$v[2]}</td> <td>{$v[4]}</td> </tr>"; }   ?></table></body>View Code

Post message display data: add.php

<! DOCTYPE html Public"-//w3c//dtd XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >PHPSession_Start();//echo $_session["username"];if(Empty($_session["Username"])){    Header("location:denglu.php"); Exit;}$username=$_session["Username"];include(".. /dbda.php ");$db=NewDbda ();$sql= "Select Name from yuangong where Username = ' {$username}‘";$attr=$db->query ($sql);//Var_dump ($attr);$_session["sender"] =$attr[0] [0];? ><div style= "color: #03F; font-size:26px "><a href=" main.php "><span> View information </span></a>&nbsp;&nbsp;& nbsp;&nbsp;&nbsp;&nbsp;<a href= "denglu.php" ><span> exit system </span></a></div><br/><br/>nbsp; <a href= "add.php" ><input type= "button" value= "reset" style= "width:100px"/></a> </td> </ Tr></table></form></body>View Code

Publish Information Processing page: addchuli.php

<?PHPSession_Start();include(".. /dbda.php ");$db=NewDbda ();$sender=$_session["Sender"];$recever=$_post["Recever"];$comment=$_post["Comment"];$time=Date("Y-m-d h:i:s", Time());$states=false;$sql= "INSERT into Liuyan values ('", ' {$sender}‘,‘{$recever}‘,‘{$time}‘,‘{$comment} ', False) ';//echo $sql;$attr=$db->query ($sql, 1);if($attr){    Header("location:main.php"); }Else{    //echo "Failure";    Header("location:add.php");}
View Code

---restore content ends---

May 26 Message Board Exercises

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.