Xing Lin Yearbook (vii) _php tutorial

Source: Internet
Author: User
Guestbook section:
Class Members Guestbook: Display message: class/notebook/index.php
Session_Start (); Start session
if (!session_is_registered ("Userregister") | | ($userregister = = "")) Check whether registration, such as Userregister is not registered or session is NULL, re-register.
{
echo "Please re-register
";
Exit
}
?>



<title>Guestbooks</title>



Include (".. /config.php ");
$result = mysql_query ("Select * from Notebook", $db);
$row =mysql_num_rows ($result);//View how many rows the query results
$max = $row; Total posts
Set to show 10 per page, can be set by itself, $p the total number of pages, $page the first few pages, $low read from the first few lines, $x read a few lines
if (! $page) {$page = 1;} $page Default value is 1
$p =ceil ($max/10);//maximum number of pages $MAX/10
$low =10* ($page-1);
if ($page = = $p && ($max%10) <>0) {$x = ($max%10);} else {$x = 10;} If it is the last page and is not an integer multiple of 10, read the remainder of $max divided by 10, otherwise take 10
if ($max ==0) {$x = 0;} If there is no post, $x take 0
$result = mysql_query ("SELECT * from Notebook order by time DESC limit $low, $x", $db);//query in descending order of the Post's time
?>





















Home
> Guestbook

echo "Total posts:", $max, "first";
for ($n =1; $n <= $p; $n + +) {
echo "$n";
}
echo "Page";
?>
Message Management

for ($i =0; $i <= ($x-1); $i + +) {
$user =mysql_result ($result, $i, ' user ');
$time =mysql_result ($result, $i, ' time ');
$ip =mysql_result ($result, $i, ' IP ');
$title =mysql_result ($result, $i, ' title ');
$nnote =mysql_result ($result, $i, ' nnote ');
$yresult = mysql_query ("SELECT * from user where user= ' $user '", $db);//Read Member database
$name =mysql_result ($yresult, 0, ' name ');
$signature =mysql_result ($yresult, 0, ' signature ');//Read personal signature
$email =mysql_result ($yresult, 0, ' email ');
$face =mysql_result ($yresult, 0, ' face ');
$face = '. /image/face/icon '. $face;

echo "






"; echo " "; echo " "; echo " "; echo " "; echo " "; echo " "; echo "
Message Person: $namePosted in: $time$ip
Title: $title
Message content: $nnote
----------------------
$signature
";
}
Mysql_close ($DB);
?>



Add Message: class/notebook/addnote.php
Session_Start (); Start session
if (!session_is_registered ("Userregister") | | ($userregister = = "")) Check whether registration, such as Userregister is not registered or session is NULL, re-register.
{
echo "Please re-register
";
Exit
}
?>



<title>Add message</title>











Include (".. /config.php ");
if ($submit) {
$time =date ("Y year m D-day h:i:s A");
$IP = $REMOTE _addr;//message IP address
$title =strip_tags ($top);
$nnote =nl2br (Strip_tags ($content));//Remove the HTML tag first, and then turn the newline character

if (! $title | |! $nnote) {//check if complete
echo "Sorry, you must fill in all the contents!"
"." Return ";
Exit }
Write to Database
$sql = "INSERT into notebook (user,time,ip,title,nnote) VALUES (' $userregister ', ' $time ', ' $ip ', ' $title ', ' $nnote ')";
$result = mysql_query ($sql, $db);
Mysql_close ($DB);
echo "The message was successful! ";
}
?>








Home
> Guestbook > Add message
View Message



"Class=" > "White12"




http://www.bkjia.com/PHPjc/316070.html www.bkjia.com true http://www.bkjia.com/PHPjc/316070.html techarticle Guestbook Part: Class Members Guestbook: Display message: class/notebook/index.php? session_start ();//Start session if (!session_is_registered ( Userregister) | | ($userregister = =)) Check ...

  • 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.