Guest Book with Oracle database paging display (1)

Source: Internet
Author: User
Tags date key connect variables query oracle database
oracle| Page | data | database | Most of the sites will take into account the interaction between users. At this time, with the message version of the function, allows users to stay here, or some of the interaction with the site information.

In the design, it can be very simple to leave only the user's short message, can also be designed to classify the nature of a very complex Web BBS system. Of course, how to create a message version of their own website, on the nature of the site and Web site developers ingenuity.

The example presented here is a simple listing of all the messages. Users can see multiple messages at a time. The back-end message of the system is the Oracle 7.x version of the database system. The database name in the example is WWW, the user account for the connection is user38 and the password is iam3849. To use this example directly, you must first execute the following SQL instructions and create a guestbook table.

CREATE TABLE Guestbook (
Serial VARCHAR2 (255) NOT NULL,
Ref VARCHAR2 (255) NULL,
ID char (8) NOT NULL,
Alias VARCHAR2 () not NULL,
IP varchar2 (1024) NULL,
Msgdate date NOT NULL,
Email VARCHAR2 (1024) NULL,
MSG varchar2 NOT NULL,
Flag char (1) Default 1,
Primary key (serial)

The above SQL field descriptions and detailed information are shown in the following table

Ordinal field name data type length field description limit Key
0 serial number serial VARCHAR2 255 NN PK
1 Reference serial number ref VARCHAR2 255 temporary Reservation

Message-Answering function with

2 Account ID char 8 user account NN

3 Anonymous alias varchar2 32 display name NN

4 URL IP varchar2 1024 internet IP

5 Time Msgdate Date NN

6 Email Email varchar2 1024

7 message content msg VARCHAR2 NN

8 display flag Flag Char 1 0: Do not display

1: Show (default)

In this section of the message version of the program, if you add user authentication function, you can leave the user's authentication account in the Guestbook data sheet to facilitate webmaster to find the wrong sender in the future. Leave the field here first and let the readers in need practice.

To use the program in this section, first install Oracle 7.x, and make sure that the sql*net on the Web Server side can successfully connect to the Oracle repository. And then, when compiling PHP, add

The--with-oracle=/home/oracle/product/7.3.2 option, of course, can be changed to other paths, as long as the path is really Oracle's path. Please refer to the relevant books for details on Oracle installation and usage.

The following procedure is to add the user's message to the guestbook message datasheet. To set the user authentication function, you can check at the beginning of the program, send a message can confirm the identity, and read the message does not have to identity check. This setting can prevent improper speech, but will not let the message function only a few people use.

Add Message program addmsg.php
Author:wilson Peng
Copyright (C) 2000
You can add the identity check function here
if (($alias!= "") and ($msg!= "")) {
Putenv ("oracle_sid=www");
Putenv ("Nls_lang=american_taiwan.zht16big5");
Putenv ("oracle_home=/home/oracle/product/7.3.2");
Putenv ("Ld_library_path=/home/oracle/product/7.3.2/lib");

Putenv ("Ora_nls=/home/oracle/product/7.3.2/ocommon/nls/admin/data");

Putenv ("Ora_nls32=/home/oracle/product/7.3.2/ocommon/nls/admin/data");

$handle =ora_logon ("User38@www", "iam3849") or die;
$cursor =ora_open ($handle);
Ora_commitoff ($handle);

$serial =md5 (rand ()) (uniqid);
$ref = "";
$id = $PHP _auth_user;
$ip = $REMOTE _addr;
$msg =base64_encode ($msg);
$flag = "1";
$query = "INSERT into guestbook (serial, ref, ID, alias, IP,
Msgdate, email, MSG, flag) VALUES (' $serial ', ' $ref ', ' $id ', ' $alias ', ' $ip ',
Sysdate, ' $email ', ' $msg ', ' $flag ');

Ora_parse ($cursor, $query) or die;
Ora_exec ($cursor);

Ora_close ($cursor);
Ora_logoff ($handle);

Header ("Location:./index.php");

} else {
? >

fill in the message

code nickname e-mail
Content cols=33>

? >

The above program in the implementation of the first check variables alias and msg whether there is information, if there is no information sent to fill out the message form to the user side, for users to fill out the message.

If the user fills in the message, presses the "Send out Message" button, then executes the first half of the program.

The program is probably divided into five parts.

1. Set the environment variables that Oracle needs
2. Connect to Oracle Database
3. Organize data into Oracle
4. End connection to Oracle
5. Close the program, display the latest message information

In setting the Oracle environment, use PHP's function putenv () to set the environment variables for the operating system layer. To use Chinese, remember to join the following line

Putenv ("Nls_lang=american_taiwan.zht16big5");

The functions of the Oracle function library are then used: Ora_logon () and so on. See Oracle database function library for details. With this function library, Oracle repositories can be easily manipulated.

Related Article

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