Home Backend Development PHP Tutorial 一个php作的文本留言本的例子_PHP

一个php作的文本留言本的例子_PHP

Jun 01, 2016 pm 12:29 PM
color name width example text

大家知道,数据库对于网络来说的重要性.由于cgi的复杂,现在asp和php mysql已经成为主流.几乎所有的个人网页都要用到留言本,可是申请的留言本很不稳定.这为网上的交流带来了诸多不便.所以,希望拥有自己的留言本的朋友越来越多.
但是,免费的个人主页支持asp和php的很少.笔者现在向您推荐奥索网,(http://www.oso.com.cn)支持php.这样您便有了能够拥有自己留言本的基础.现在,我就通过一个文本留言本的例子来讲述php的简单使用.
首先,我们先确定,留言的几个过程:写留言,发送,查看.(搜索)等等.而且对于斑竹来说,管理留言本又是不可或缺的.这样我们就不妨定位于6个php文件,1个文本文件.6个php文件分别为:guest.php manage.php reply.php sys.php del.php edit.php,1个文本文件为:guest.txt
先来看看guest.php的内容,你当然可以直接将下面的内容放到您的php网页里,请尊重作者的劳动,谢谢.
----------------------
//guest.php:

require("sys.php");
if ($B1)
{
if ($message=="" or $name=="")
{
$errorm="出错了!!!姓名和留言内容必填";
}
else
{
#写入数据
$space = " ";
$time = date(Y年m月d日H小时i分);
$ip=$REMOTE_ADDR;
$name=encode($name);
$homepage=encode($homepage);
$from=encode($from);
$email=encode($email);
$message=StripSlashes($message);
$message=htmlspecialchars($message);
$message=check_strlen_long($message);
$message=nl2br($message);
$guestcontent = "

留言内容:



 
include('head.htm');?>



if ($errorm)
{
echo "";
echo "";
echo "";
}
?>























";
echo "$errorm";
echo "
姓名(必填)

主页:

来自:

Email:


请留言(必填)






   

















管理密码:

 









请输入关键字:





function search($keyword)
{
global $content;
$count=count($content);
$subscript=0;
$ArrSearch=array();
for ($i=0;$i {
if (ereg($keyword,$content[$i]))
{
$ArrSearch[$subscript]=ereg_replace($keyword,"$keyword",$content[$i]);
$subscript ;
}
}
return $ArrSearch;
}//end function
$one_page_line=15;
$content = file($guestfile);
if (isset($search) and isset($keyword) and $keyword!="")
{
$content=search($keyword);
}
$count =count($content);
?>







$int_page_count=$count;//总条数;
$int_page_num=ceil($int_page_count/$one_page_line);//总页数;
echo "分页:";
for ($i=1;$i {
echo "".$i." ";
}
echo "
";
if (isset($search) and isset($keyword) and $keyword!="")
{
echo "
";
echo "下面的留言中包含关键字$keyword".$count."
";
}
?>

共有







if ($page=="" or !isset($page))
{$page=1;}
$text="";
$begin_line=$int_page_count-($page-1)*$one_page_line;
if ($begin_line for ($j=$begin_line;$j>($begin_line-$one_page_line);$j--)
{
$text=$text."";
$text.=$content[$j-1];

//数组找下标从0开始.
}

echo "$text";
?>
回复 编辑 删除 第$j


include('bottom.htm');
?>

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What are constants in C language? Can you give an example? What are constants in C language? Can you give an example? Aug 28, 2023 pm 10:45 PM

A constant is also called a variable and once defined, its value does not change during the execution of the program. Therefore, we can declare a variable as a constant referencing a fixed value. It is also called text. Constants must be defined using the Const keyword. Syntax The syntax of constants used in C programming language is as follows - consttypeVariableName; (or) consttype*VariableName; Different types of constants The different types of constants used in C programming language are as follows: Integer constants - For example: 1,0,34, 4567 Floating point constants - Example: 0.0, 156.89, 23.456 Octal and Hexadecimal constants - Example: Hex: 0x2a, 0xaa.. Octal

How to search for text across all tabs in Chrome and Edge How to search for text across all tabs in Chrome and Edge Feb 19, 2024 am 11:30 AM

This tutorial shows you how to find specific text or phrases on all open tabs in Chrome or Edge on Windows. Is there a way to do a text search on all open tabs in Chrome? Yes, you can use a free external web extension in Chrome to perform text searches on all open tabs without having to switch tabs manually. Some extensions like TabSearch and Ctrl-FPlus can help you achieve this easily. How to search text across all tabs in Google Chrome? Ctrl-FPlus is a free extension that makes it easy for users to search for a specific word, phrase or text across all tabs of their browser window. This expansion

Try new ringtones and text tones: Experience the latest sound alerts on iPhone in iOS 17 Try new ringtones and text tones: Experience the latest sound alerts on iPhone in iOS 17 Oct 12, 2023 pm 11:41 PM

In iOS 17, Apple has overhauled its entire selection of ringtones and text tones, offering more than 20 new sounds that can be used for calls, text messages, alarms, and more. Here's how to see them. Many new ringtones are longer and sound more modern than older ringtones. They include arpeggio, broken, canopy, cabin, chirp, dawn, departure, dolop, journey, kettle, mercury, galaxy, quad, radial, scavenger, seedling, shelter, sprinkle, steps, story time , tease, tilt, unfold and valley. Reflection remains the default ringtone option. There are also 10+ new text tones available for incoming text messages, voicemails, incoming mail alerts, reminder alerts, and more. To access new ringtones and text tones, first, make sure your iPhone

Using large models to create a new paradigm for text summary training Using large models to create a new paradigm for text summary training Jun 10, 2023 am 09:43 AM

1. Text task This article mainly discusses the method of generative text summarization, and how to use contrastive learning and large models to implement the latest generative text summarization training paradigm. It mainly involves two articles, one is BRIO: Bringing Order to Abstractive Summarization (2022), which uses contrastive learning to introduce ranking tasks in the generative model; the other is OnLearning to Summarize with Large Language Models as References (2023), which further introduces large models to generate high-quality training data based on BRIO. 2. Generative text summarization training methods and

What to do if win7 system cannot open txt text What to do if win7 system cannot open txt text Jul 06, 2023 pm 04:45 PM

What should I do if win7 system cannot open txt text? When we need to edit text files on our computers, the easiest way is to use text tools. However, some users find that their computers cannot open txt text files. So how to solve this problem? Let’s take a look at the detailed tutorial to solve the problem of unable to open txt text in win7 system. Tutorial to solve the problem that win7 system cannot open txt text. 1. Right-click any txt file on the desktop. If there is no txt file, you can right-click to create a new text document, and then select properties, as shown below: 2. In the opened txt properties window , find the change button under the general options, as shown in the figure below: 3. In the pop-up open mode setting

After chatting online for a month, the pig-killing scammer was actually defeated by AI! 2 million netizens shouted shocked After chatting online for a month, the pig-killing scammer was actually defeated by AI! 2 million netizens shouted shocked Apr 12, 2023 am 09:40 AM

Speaking of "pig killing plate", everyone must hate it with itch. In this type of online dating and marriage scams, scammers will look for victims in advance who are easy to fall for, and they are often innocent, kind-hearted and well-behaved girls with beautiful fantasies about love. In order to fight these scammers for 500 rounds, "Turing's Cat", a well-known up-and-comer in the technology circle at Station B, trained an AI that frequently makes hilarious jokes in chat, and is even better than a real person. As a result, with the operation of AI, the scammer was confused by this fake lady and directly transferred 520 to "her". What’s even funnier is that after discovering that the scammer had no chance to take advantage of him, not only did he break his defense, but he was also given a “famous quote” by the AI: As soon as the video came out, it immediately went viral, and friends surfing at station B were all fooled.

How to copy text from screenshots on Windows 11 How to copy text from screenshots on Windows 11 Sep 20, 2023 pm 05:57 PM

Download the new Snipping Tool with text actions Although the new Snipping Tool is limited to development and canary versions, if you don’t want to wait, you can install the updated Windows 11 Snipping Tool (version number 11.2308.33.0) now. How this works: 1. Go ahead and open this website (visit) on your Windows PC. 2. Next, select "Product ID" and paste "9MZ95KL8MR0L" into the text field. 3. Switch to the "Quick" ring from the right drop-down menu and click Search. 4. Now, look for this version “2022.2308.33.0” in the search results that appear. 5. Right click on the one with MSIXBUNDLE extension and in context menu

What does the width of html mean? What does the width of html mean? Jun 03, 2021 pm 02:15 PM

In HTML5, width means width. The width attribute defines the width of the element's content area. You can add inner margins, borders, and outer margins outside the content area. You only need to set "element {width: value}" to the element.

See all articles