PHP Simple Message Board tutorial a

Source: Internet
Author: User

As a message board, let's take a look at the files in the picture below to refer to those.

Global.php is a global file that has data link code. index.php is the display file does not need to say the following have explained, login.php login file, logout.php exit login, madd.php add message, mreplay.php reply message, OK, let's take a look at the code for the global.php file first.

<?php
@header ("content-type:text/html; Charset=utf-8 ");
$dbhost = ' localhost ';//Database server
$dbuser = ' root ';//database user name
$dbpwd = ';//Database Password
$dbname = ' DEMO_GB ';//Database name

$db =mysql_connect ($dbhost, $dbuser, $dbpwd) or Die (') to connect to the database. ');
mysql_select_db ($dbname, $db) or Die (' cannot connect to the database. ');
mysql_query ("Set names ' UTF8 '");
?>

This is all database connection functions Oh.

Now see logout.php here to remove the Sesson OK. The code is as follows.

<?php
  @header ("content-type:text/html; Charset=utf-8 ");
 session_start ();
 if (Session_destroy ())
 {
 echo ("Out ok!");
 //window.alert (' Exit succeeded! ')
 die ("<script>;window.location.href= ' index.php ';</script>");
 }
 else echo "Out false" and "Go Back";
 //header ("location:index2.php");
?

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.