Home  >  Article  >  Backend Development  >  Use PHP to connect to the database to implement the message board function

Use PHP to connect to the database to implement the message board function

巴扎黑
巴扎黑Original
2017-09-14 10:19:421498browse

The editor below will bring you an example of using PHP to connect to the database to implement the message board function (recommended). The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor and take a look.

PHP implements the message board function:

1 The first is the login page:




 
  
  留言板登录
  
  
  
 

开发部内部留言板

用户名:

口令:

2 After the login page is completed, you need to enter the login processing page, which is the messloginchuli.php submitted above


query($sql,0);
//var_dump($arr[0][0]);
if($arr[0][0]=$pwd && !empty($pwd)){
 $_SESSION["uid"]=$uid;
 header("location:message.php");
}

?>

The login page looks like this:

3. After the login is completed, you will enter the home page. The following is the table of the designed database and the code of the main page:


##



 
  
  
  
  
  
 

发布信息 退出系统

query($sql,0); foreach($arr as $v){ echo ""; } ?>
留言信息:
发送人 发送时间 接收人 信息内容
{$v[1]} {$v[2]} {$v[3]} {$v[4]}

Exit the login system to implement user logout and return to the login page. The function code is as follows:


 

The code is written here, and the more important part is completed. Below It is time to enter the release information page, which is equivalent to the added page written before. The processing page is no different from before. The difference is that the current processing page is operated when the user is logged in, and all logins need to be logged in using session. The pages under the circumstances are connected

The effect of the main page is as shown in the figure:

4. The last is the information release page, where you can send information to anyone

The code is as follows:

##



 
  
  发布信息界面
  
  
  
 

查看信息 查看发送信息


Send The information page is as shown in the figure:

5. After publishing the information, you have to enter the processing page, which is the submitted infochuli.php, and finally return to send Information interface

query($sql);
if($arr && !empty($arr)){
 header("location:publish_info.php");
}else{
 echo "发送失败!";
}

?>

The above is the detailed content of Use PHP to connect to the database to implement the message board function. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn