Build a guestbook with PHP_PHP tutorial
The following is the configuration description: For the convenience of configuration, the code has been rearranged. Now all the parameters that need to be set have been placed in the config.php file. It should be very simple to configure, and there are detailed instructions in it. Goal: In Get your guestbook ready within ten minutes!!! 1: Create a database (the homepage must provide database space). Generally, there is a front-end of phpMyAdmin open source. It is very simple to create. After choosing a name, remember to add config.php Change $db_name to this name 2: Create a message data table (change $table_name in config.php to the name you gave here later). The structure is: key_liuyan int(11) auto_increment primary key, //Main creation, automatic Add nikename varchar(20) null // Nickname subject varchar(100) null // Message subject date_created varchar(19) // Message time ip_address varchar(15) // Message person's IP address message mediumtext null // Message information email_address varchar (50) null // The e-mail address of the person who left the message zhuye_address varchar(50) null // The homepage address of the person who left the message huifu_biaozi int(1) default 0 // Moderator reply flag huifu mediumtext null // Moderator reply content oicq varchar (20) null // The OICQ number of the person who left the message can be completed using the following SQL!!! (I passed the test, remember to change yourtable_name to something easier to remember, of course you can leave it alone) create table your_liuyan_table( Key_liuyan int( 11) auto_increment primary key, nikename varchar(20) null, subject varchar(100) null, date_created varchar(19) , ip_address varchar(15), message mediumtext null, email_address varchar(50) null, zhuye_address varchar(50) null, huifu_biaozi int(1) default 0, huifu mediumtext null, oicq varchar(20) null ) 3: Create a control table: (Similarly put the name here in $table_name_control of config.php) The structure is as follows: leibie varchar( 20) primary key, value varchar(20) null You can also use the following SQL statement: create table your_control_table( leibie varchar(20) primary key, value varchar(20) null ) Because this is your control table, you have to add it yourself There are two control records; The SQL statement is: Insert and delete password: insert into your_control_tble( leibie, value) values (delete,1332); Insert reply password: insert into your_control_tble( leibie, value) values (huifu,1332); Put it in like this The password is: 123, and the user name is empty! How to calculate the relationship between the password and the inserted value? This is it, your password, such as 123, add up the three digits, equal to 6, and then multiply 6 222 is the password value!!! 6*222=1332. Knowing this relationship, of course you can change it to another password. But the user name must be empty,,, 4: After everything is completed, just add the exceptions to readme.txt Just upload the file. post.php file <?php require(config.php); ?> <?php $nikename=$arr_request[nikename]; if (strlen($nikename)==0) { echo "<center >"; echo "<h2><font color=red>Error message!</font></h2>"; echo "Sorry, the name of <font color=red></font> must be filled in!!! Please try again Fill in!<br>"; echo "<hr></hr>"; echo "The free guestbook is technically supported by <a href=http://little.oso.com.cn>Little Bear</a>"; echo "</center>"; exit ; } $date_now=date(Y/m/d H:i:s); $ip_address=getenv("REMOTE_ADDR"); $messageold=$arr_request[message]; //$ pattern="/n/"; //$replacement="<br>"; $message=computer_message($messageold,$hang_zifu_number); $subjectold=$arr_request[subject]; if (strlen($subjectold)>$hang_zifu_number ) $subject=computer_message($subjectold,$hang_zifu_number); else $subject=$subjectold; $str_sql=" insert into $table_name (nikename,subject,date_created,ip_address,message,email_address,zhuye_address,oicq) values ( $nikename, $subject, $date_now, $ip_address, $message, ".$arr_request[email_address].", ".$arr_request[zhuye_address].", ".$arr_request[oicq]." )"; $result=mysql_db_query($ db_name,$str_sql,$id_link); if (! $result){ affy_error_exit(SQL Insert Execution has failed.); } else { echo "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">"; echo "<HTML><HEAD><TITLE>Publish article</TITLE>"; echo "<META content="text/html; charset=gb2312" http-equiv=Content-Type>"; echo " <meta HTTP-EQUIV="REFRESH" CONTENT="2;URL=display.php">"; echo "</head><body topmargin="0"><br>"; echo "<ul>Thank you for posting Leave a message, the message content will be automatically displayed"; echo " <br>"; echo "<a href=display.php>If your browser does not automatically return to the guestbook homepage? Please click here to return."; echo " </a></ul>"; exit; } ?> index.html file<html> <center> <title>Thank you for your message! </title> <h1><font color=blue>My guestbook</font></h1> <font color=navy>First of all, thank you for your message. I will read every word you say carefully! ! !</font> <form action="post.php" method="post"> <table> <tr> <td><font color=teal>呢称:</font><font color=red>(不能为空)</font></td><td> <input type="text" name="nikename" value=""></td> </tr> <tr> <td>OICQ号码:</td><td> <input type="text" name="oicq" value=""></td> </tr> <tr> <td>e-mail: </td><td> <input type="text" name="email_address" value="" size="30"></td> </tr> <tr> <td>个人主页:</td><td> <input type="text" name="zhuye_address" value="http://" size="40"></td> </tr> <tr><td> 主题:</td><td> <input type="text" name="subject" size="40" ></td> </tr> <tr><td> 内容:</td><td> </td> </tr> <tr><td colspan="2"> <textarea name="message" cols="60" rows="8"></textarea></td> </tr> <tr> <td> <input type="submit" value="完成留言"> </td> <td> <input type="reset" value="重新来过"> </td> </tr> </table> </form> <p> <a href=display.php>查看留言</a> <hr></hr> 免费留言本由<a href="http://little.oso.com.cn" >小熊</a>提供技术支持 </center> </html> display.inc文件!!! <tr bgcolor=> <td> <a href=mailto:<?php echo $record->email_address ?> > <font color="blue" size=4><strong><?php echo $record->nikename ?></strong></font> </a> </td> <td><font color="navy">留言时间:<?php echo $record->date_created ?></font></td> <td>来自: <?php $ip_address=ip_question($record->ip_address); echo $ip_address; ?> </td> </tr> <tr bgcolor=> <th colspan=3 align=left>主题:<font color=teal><?php echo $record->subject ?></font></th> </tr> <tr><th colspan=3 align=left><font color="#416AAF"> <?php echo $record->message ?></font></th> </tr> <?php if ($record->huifu_biaozi) { ?> <tr><th colspan=3 align=left><font color="red"><br><br>版主回复:</font><font color="navy"> <?php echo $record->huifu ?></font></th> </tr> <?php } ?> <tr> <th colspan=3 align=left><br> <a href=mailto:<?php echo $record->email_address ?> > <img src=image/mail.gif alt="<?php echo $record->nikename ?>的e-mail地址是:<?php echo $record->email_address ?> " border="0" width="15" length="15">邮件</a> <a href=<?php echo $record->zhuye_address ?>><img src=image/home.gif alt="<?php echo $record->nikename ?>的主页地址是:<?php echo $record->zhuye_address ?> " border="0" width="14" length="14" >主页</a> <img src=image/oicq.gif border="0" alt="<?php echo $record->nikename?>的OICQ是: <?php echo $record->oicq ?>" width="14" length="14" >OICQ</a> <a href=action.php?action=delete&key_liuyan=<?php echo $record->key_liuyan ?>><img src=image/del.gif border="0" width="12" length="12" alt="只有版主才有删除的权限哦!">删除</a> <a href=action.php?action=huifu&key_liuyan=<?php echo $record->key_liuyan ?> ><img src=image/replay.gif border="0" width="14" length="14" alt="不好意思,现在暂时只有版主才能回复">回复</a> </th></tr> <tr> <td colspan="3"><hr SIZE ="1"></td> </tr>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.
