PHP simple message book function implementation code, php message book code

Source: Internet
Author: User

PHP simple message book function implementation code, php message book code

This example shares the code of the PHP message book function for your reference. The details are as follows:

Index. php

<? Php error_reporting (0); // The require_once "conn. php "; $ pagesize = 5; // 5 pieces of data are displayed on each page $ SQL =" select count (*) from guestlist "; // select a database, calculate the number of rows that meet the condition and return the number of rows $ result = mysql_query ($ SQL); // run the statement. If the execution succeeds, the result set is returned (all data is found from the database and the number of rows is returned) $ row = mysql_fetch_row ($ result); // obtain the Array [0] = "Total number of entries in the database" $ infoCount = $ row [0]; // obtain the total number of entries: get the value $ row [0] = "Total number of items in the Database" $ pageCount = ceil ($ infoCount/$ pagesize) in the array ); // obtain the total number of pages (total number/number of pages per page 5) $ currpage = emp Ty ($ _ GET ["page"])? 1: $ _ GET ["page"]; // if the current page is empty, define page = 1, that is, $ currpage = 1, and vice versa. if ($ currpage> $ pageCount) // if the number of pages entered exceeds the total number of pages, the last page is displayed by default. {$ currpage = $ pageCount;}?> <! DOCTYPE html> 

Conn. php

<? Php $ link = mysql_connect ("localhost", "root", ""); mysql_select_db ("guestbook"); mysql_query ("set names UTF-8"); if (! $ Link) {die ("Connection failed:". mysqli_connect_error ();} // echo "link successful";?>

Result. php

<? Php error_reporting (0); // The require_once "conn. php "; $ title = $ _ REQUEST ['title']; $ username = $ _ REQUEST ['username']; $ content = $ _ REQUEST ['content']; $ content = str_replace ("\ n", "<br>", str_replace ("", "", $ content )); // display 'space' and 'Carriage return '$ week = 'Week '. mb_substr ("May 25, 1234", date ("w"), 1, "UTF-8"); $ isok = mysql_query ("insert into guestlist (title, username, content, addtime) values ('$ title',' $ username', '$ c Ontent ','". date ("Y-m-d H: I: s "). "$ week ')"); if ($ isok) {echo "<script> alert ('submitted successfully'); location. href = 'index. php'; </script> ";}else {echo" <script> alert ('submission failed'); location. href = 'index. php'; </script> ";}?>

Css/index.css

Body {margin: 0; padding: 0;} ul, li {list-style: none; margin: 0; padding: 0;} a {text-decoration: none ;}. content {width: 800px; margin: 0 auto ;}. bt {width: 799px; height: 20px; text-align: center; background: # EB9316; margin: 0 0 5px 0 ;}. bt> li {float: left; width: 265px; height: 20px; text-align: center; line-height: 20px; font-size: 13px ;}. nr {float: left;/* lynr after not floating will be affected */width: 799px; height: 20px; text-align: center; background: # B9DEF0 ;}. nr> li {float: left; width: 265px; height: 20px; text-align: center; line-height: 20px; font-size: 13px ;}. lynr {float: left;/* layout will be messy if not floating */width: 800px; margin: 1px 0 1px 0 ;}. content p {width: 70px; height: 50px; float: left ;}. content span {display: block; width: 710px; float: left;} td {width: 80px; padding: 5px 0;/* border: 1px solid #79 ABFE; */} td input, textarea {border: 1px solid #79 ABFE;}/* tr {display: block; /* Set tr to block element. After the block element is displayed, it is surrounded by not a rectangle }*/

Dist/css/bootstrap.min.css (download by yourself)

:

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

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.