Build a message book with PHP

Source: Internet
Author: User
The following is a description of the configuration:

In order to configure the convenience, the reorganization of the code, has now put all the required parameters are placed in the config.php file, configuration should be very simple, there are Shishi instructions.
Objective: To get your message in very kind!!!

1: Establish a database (to provide database space to the home page)

The general phpMyAdmin is the front end of the open source Ma. It's very simple since it was created. After you get your name, remember to change config.php's $db_name to that name.

2: The establishment of the Message data table (wait for the config.php $table_name to change to Here you name).

Structure is:

Key_liuyan Int (one) Auto_increment primary key,//main built, automatically added
Nikename varchar () NULL//Nickname
Subject varchar (MB) NULL//Message theme
date_created varchar (19)//Message time
IP_Address varchar (15)//Message person's IP address
Message Mediumtext NULL//messages
email_address varchar (x) NULL//e-mail address of the message person
zhuye_address varchar (%) null//home address of the message person
Huifu_biaozi int (1) default 0//Moderator reply flag
Huifu mediumtext Null/Moderator reply content
OICQ varchar () NULL//OICQ number of the message person

The following SQL can be used to complete the!!! (I test through, remember to change the yourtable_name to a good point of note, of course, do not change the line AH)

CREATE TABLE Your_liuyan_table (
Key_liuyan Int (one) Auto_increment primary key,
Nikename varchar () NULL,
Subject varchar (MB) NULL,
date_created varchar (19),
IP_Address varchar (15),
Message Mediumtext NULL,
email_address varchar (m) NULL,
zhuye_address varchar (m) NULL,
Huifu_biaozi int (1) default 0,
Huifu mediumtext NULL,
OICQ varchar () null
)

3: Set up the control table: (also to put the name of this place into the config.php $table_name_control)

The structure is as follows:

Leibie varchar () primary key,
Value varchar () null

You can also use the following SQL statement:

CREATE TABLE Your_control_table (

Leibie varchar () primary key,
Value varchar () null
)

Because this is your control sheet, so you have to add control records two;

The SQL statement is:

Insert 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 ');

The password put in this way is: 123, the user name is empty!

How do you calculate the relationship between the password and the inserted value?

So, your password, like 123 of the three-digit numbers, equals 6, and then the 6 times 222 is the cipher value!!!

6*222=1332.

Knowing the relationship, of course, you can change it to another password.

However, the user name is empty,,,

4: It's all done, then just upload the file except Readme.txt.

post.php file
<?php
Require (' config.php ');
? >

<?php

$nikename = $arr _request[' nikename '];

if (strlen ($nikename) ==0)
{
echo "<center>";

echo "<font color=red> error message! </font>";
echo "Sorry, <font color=red> said </font> must be filled out!!! Please refill! <br>;
echo "echo "free message book by <a href=http://little.oso.com.cn> Little Bear </a> provide technical support";
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 "echo "<ul> Thank you for your message, will automatically display the message content";
echo "<br>";
echo "<a href=display.php> If your browser does not automatically return to the Guest Book home page,?
Please click here to return. ";
echo "</a> </ul>";

Exit

}
? >

index.html file

<center>

<title> Thank you for the message! </title>
<font color=blue> My message this </font>
<font color=navy> First of all thank you for your message, every word of yours I will read CAREFULLY!!! </font>

<form action= "post.php" method= "POST"
<table>
<tr>
<td> <font color=teal> said: </font> <font color=red> (cannot be empty) </font> </td> <td>
<input type= "text" name= "Nikename" value= "" > </td>
</tr>

<tr>
<td> OICQ Number: </td> <td>

<input type= "text" name= "Oicq" value= "" > </td>
</tr>
<tr>
<td> e-mail: </td> <td>
<input type= "text" name= "email_address" "value=" "size=" ">" "</td>
</tr>
<tr>
<td> Personal Home page: </td> <td>
<input type= "text" name= "zhuye_address" value= "http://" size= "" "> </td>
</tr>
<tr> <td>
Topics: </td> <td>
<input type= "text" name= "subject" size= "" "> </td>
</tr>
<tr> <td>
Content: </td> <td> </td>
</tr>
<tr> <td colspan= "2" >
<textarea name= "message" cols= "rows=" "8" > </textarea> </td>
</tr>
<tr>
<td>
<input type= "Submit" value= "complete message" >
</td>
<td>
<input type= "reset" value= "Again"
</td>
</tr>
</table>
</form>
<p>
<a href=display.php> View Message </a>
Free message by <a Href= "http://little.oso.com.cn" > teddy Bear </a> provide technical support

</center>


DISPLAY.INC file!!!


<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" > message time: <?php echo $record->date_created? > </font> </td>

<td> from:

<?php
$ip _address=ip_question ($record->ip_address);
echo $ip _address;
? >

</td>
</tr>
<TR bgcolor=>
<th colspan=3 align=left> Theme: <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> Moderator reply: </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? > >
alt= "<?php echo $record->nikename?" e-mail address is: <?php echo $record->email_address? > "
Border= "0" width= "length=" 15 "> message </a>
<a href=<?php Echo $record->zhuye_address? >>alt= "<?php echo $record->nikename?" The home page address is: <?php echo $record->zhuye_address? > "
Border= "0"
Width= "Length=" "14" > home </a>
<?php nikename?> Echo $record Oicq is:
<?php echo $record->oicq? > "
Width= "Length=" >oicq </a>

<a href=action.php?action=delete&key_liuyan=<?php Echo $record->key_liuyan? >> delete </a>
<a href=action.php?action=huifu&key_liuyan=<?php Echo $record->key_liuyan? > > reply </a>

</th> </tr>

<tr>
<TD colspan= "3" ></tr>



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.