Build a message book with PHP

Source: Internet
Author: User
Use PHP to construct a message book. The following describes the configuration: <br/> for convenience of configuration, the code is reorganized, now all the parameters to be set have been placed in config. the configuration instructions are as follows:

For the convenience of configuration, the code has been reorganized. now all the parameters to be set have been put in the config. php file. the configuration should be very simple and detailed descriptions are provided.
Goal: Get your message book in a very short time !!!

1: create a database (to provide database space on the homepage)

The front-end of phpMyAdmin open source Ma is generally available. it is very simple since it was created. after obtaining the name, remember to change $ db_name of config. php to this name.

2: Create a message Table (Change $ table_name of config. php to your name here ).

Structure:

Key_liuyan int (11) auto_increment primary key, // master creation, automatically added
Nikename varchar (20) null // nickname
Subject varchar (100) null // message topic
Date_created varchar (19) // message time
Ip_address varchar (15) // IP address of the contact
Message mediumtext null // message
Email_address varchar (50) null // the email address of the contact
Zhuye_address varchar (50) null // The homepage address of the contact
Huifu_biaozi int (1) default 0 // moderator reply flag
Huifu mediumtext null // moderator reply content
Oicq varchar (20) null // The OICQ number of the contact

You can use the following SQL statement to complete the process !!! (If I pass the test, remember to change yourtable_name to a good note. of course, you can do it without changing it)

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: (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 must add two control records on your own;

The SQL statement is:

Insert and delete a password:

Insert into your_control_tble (leibie, value)
Values (delete, '20140901 ');

Insert the reply password:

Insert into your_control_tble (leibie, value)
Values (huifu, '123 ');

The password entered here is: 123, and the user name is blank!

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

That's right. your password, for example, 123 adds up all three digits, equals 6, and then multiply 6 by 222 is the password value !!!

6*222 = 1332.

Now that you know the relationship, you can change it to another password.

However, the username must be blank ,,,

4: after all, you only need to upload the files except readme.txt.

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

<? Php

$ Nikename = $ arr_request ['nikename'];

If (strlen ($ nikename) = 0)
{
Echo "<center> ";

Echo "Echo "Sorry, <font color = red> it is required </font> !!! Please fill in again! <Br> ";
Echo "Echo "free message book provided by <a href = http://little.oso.com.cn> cubs </a> 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 ['subobject'];
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 ',
'$ Subobject ',
'$ 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> Post </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 posting your message. the message content will be displayed automatically ";
Echo "<br> ";
Echo "<a href = display. php> if your browser does not automatically return to the homepage of the message book ,?
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 message book </font> <Font color = navy> First of all, thank you for your message. I will read every sentence carefully !!! </Font>

<Form action = "post. php" method = "post">
<Table>
<Tr>
<Td> <font color = teal> </font> <font color = red> (cannot be blank) </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> Email: </td> <td>
<Input type = "text" name = "email_address" value = "" size = "30"> </td>
</Tr>
<Tr>
<Td> personal homepage: </td> <td>
<Input type = "text" name = "zhuye_address" value = "http: //" size = "40"> </td>
</Tr>
<Tr> <td>
Topic: </td> <td>
<Input type = "text" name = "subject" size = "40"> </td>
</Tr>
<Tr> <td>
Content: </td>
</Tr>
<Tr> <td colspan = "2">
<Textarea name = "message" cols = "60" rows = "8"> </textarea> </td>
</Tr>
<Tr>
<Td>
<Input type = "submit" value = "complete message">
</Td>
<Td>
<Input type = "reset" value = "coming again">
</Td>
</Tr>
</Table>
</Form>
<P>
<A href = display. php> View message </a>
<Hr> Free message book provided by <a href = "http://little.oso.com.cn"> cubs </a> Technical Support

</Center>

</Html>

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> Topic: <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> 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?> The email address of is: <? Php echo $ record-> email_address?> "
Border = "0" width = "15" length = "15"> email </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 = "14" length = "14"> homepage </a>
nikename?> The OICQ of is:
<? Php echo $ record-> oicq?> "
Width = "14" length = "14"> 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.