The following small series for everyone to bring a PHP connection to the database to implement the message board function of the example explained (recommended). Small series feel very good, now share to everyone, also for everyone to make a reference. Let's take a look at it with a little knitting.
PHP Implementation message Board function:
1 First login page:
<! DOCTYPE html>
2 Login page After completion to enter the login processing page, that is, the above submitted to the messloginchuli.php
<?phpsession_start (); After login to connect the included login page, open session$uid = $_post["UID"]; $pwd = $_post["pwd"];require_once "./dbda.class.php"; $db = new Dbda (); $sql = "Select password from Yuangong where username= ' {$uid} '"; $arr = $db->query ($sql, 0);//var_dump ($arr [0][0]); if ($arr [0][0]= $pwd &&!empty ($pwd)) {$_session["UID"]= $uid; Header ("location:message.php");}? >
Login page Effects
3. After the login is completed, it is to enter the main page, that is, to display the conversation you received, the following is the design of the database table and main page code:
<! DOCTYPE html>
Log out of the system to implement user logoff, return to the login page function code as follows:
<?phpsession_start (); $uid = $_session["UID"];unset ($uid); Header ("location:messlogin.php"); >
The code is written here, the more important part is completed, the following is to enter the publishing information page, the equivalent of the previous write the added page, its processing page is not the same as before, the difference is that the current processing page in the case of user login operation, You need to use the session to connect all the pages in the login situation
Main Page effects
4. Finally, the Information publishing page, you can send information to anyone
The code is as follows:
<! DOCTYPE html>
Send Information page
5. After completion of the release information to enter the processing page, which is submitted to the infochuli.php, and finally return to send the information interface
<?phpsession_start (); $uid = $_session["UID"); $recever = $_post["Recever"]; $content = $_post["Content"]; $arr = $_ post["Recever"]; $t = Date ("y-m-d h:i:s"); require_once "./dbda.class.php"; $db = new Dbda (); $sql = "INSERT INTO Liuyan value S (', ' {$uid} ', ' {$t} ', ' {$recever} ', ' {$content} ', 0) ', $arr = $db->query ($sql); if ($arr &&!empty ($arr)) { Header ("location:publish_info.php");} else{echo "Send failed!";}? >