ASP,PHP,JSP Technology to build e-commerce platform

Source: Internet
Author: User
Tags getmessage odbc mysql net command php and php code stmt oracle database
js| e-commerce

1. Introduction: The current dynamic web design technologies are: the use of perl/c++/delphi, such as the development of CGI, two well-known api-isapi/nsapi, as well as ColdFusion, and in recent years popular 3p technology-asp,php, JSP (according to the Internet on the site statistics about nearly hundreds of); Asp-ative server Page, developed by Microsoft, is a Web server-side development environment, mainly in scripting language VBScript (or javascript/ Perl, etc.) as your own development language, you can access the Windows Platform database using ODBC or direct drive. Php-person Server Page is a cross-platform, server-side embedded scripting language created by the Rasmus individual. It borrows heavily from the syntax of the C,java and Perl languages, and is coupled with PHP's own features. It's a very personalized web development language that supports the vast majority of databases today. Jsp-java Server Page, a new generation of web development languages launched by Sun, has created JSP in addition to Java applications and Java applets, which can be supported by Serverlet and JavaBean Complete powerful site program development, especially with a number of ways to access the database. In the electronic commerce platform design, the main need solves "the website structure Design", "Registration Interface", "" Trading Interface "," Backstage Database ", and" supporting modules "such as shopping/user/forum/Feedback/search/conversation design, considering the length, this article only gives the unified foreground interface and the background database 3p design method It can be said that the operation of asp,php,jsp and network database is a strong cornerstone of E-commerce website platform design.

2. Construction of three kinds of design technology operating environment 2.1 Build ASP's operating environment: nt5.0server,iis5.0, ASP3.0. Select IIS5.0 Options when installing Windows2000server (nt5.0server). After installation, ASP3.0 is embedded in the IIS5.0. Test asp: Start browser, lose in Address bar127.0.0.1: 80/default.asp, if you browse to the ASP welcome page of the IIS server, the installation is successful 2.2 build PHP4 operating Environment: Nt5.0server, Apache1.3.12 php4.0 Install support PHP Web server Apache1.3.12, the Apache server compressed files uncompressed, according to the prompts for the entire installation process, choose to install to the directory D:\apache. Install PHP4, PHP4 compressed files to D:\PHP4, and then copy php.ini-dist files to the Winnt directory, the file renamed to PHP.ini, open the file Extension_dir set it to: D:/PHP4, and loading the extension module: the document contains; Extention=*.dll the ";" The number can be removed; Modify the settings Aphache Server, edit the directory D:\aphache directory in a text editor under the table named httpd.conf text file, the first "#ServerName *" under the line to add "" ServerName127.0.0.1/", and then change" Port 80 "to" port 81 (or other ports that do not conflict with IIS5.0) ", and then set the Apache virtual directory to be changed to" DocumentRoot "D:/apache/htdocs" to DocumentRoot "D :/trade "(This directory is an E-commerce Web site directory, can be established in any way to create a directory trade), and finally add the following statement to support PHP4: scriptalias/php4/" d:/php4/"AddType application/ x-httpd-php. php addtype application/x-httpd-php. phtml Action application/x-httpd-php4 "/php4/php.exe"; test PHP: After completing the above steps , in the D:\trade directory, use the text editor to generate file test.php with the extension. PHP (or phtml), enter the following PHP code in the file, save it, start Apache, and then you type in the browser127.0.0.1: 81/test.php, if you see the version of PHP and extension modules and other information, the installation of the environment is successful. 2.3 Build JSP Operating Environment: nt5.0server,resin1.13, jdk1.3 install Java compiler jdk1.3: Run Jdk1_3-win.exe, follow the prompts to complete the installation can be installed in the d:\java1.3 directory, can also be installed in other directories. Set system Environment Parameters: Control Panel/System/Environment page Select Path parameter to add D:\jdk1.3\bin; Add new environment parameter Classpath=d:\jdk1.3\lib\tools.jar;d:\jdk1.3\lib\dt.jar; Then restart the computer to install the Web server Resin1.1.3 that supports JSP, and release Resin-1.1.3.zip as d:\Resin1.1.3. Configure the server port and open the resin.conf file in the d:/resin1.1.3/conf/directory

8080 tab to set the port to 82 (on my NT5.0 three servers, so that three server ports are iis:80; apache:81; Resin:82 can also be set to other conflicting port numbers as well. Test JSP: Start the resin server, start the browser, in the address bar 127.0.0.1: 82/, if you browse to the Resin server JSP Welcome page, indicating the installation success

3. generate dynamic form pages in three formats for general use, here are examples of possible form objects, as in the following fields used to design specific data tables, Just turn to the corresponding object for the form field given. 3.1 Using ASP to dynamically generate data exchange with the database of the Operation form: form.asp: Generate form Field headers: Generate normal text: Generate password text: Generate scrolling text: Build a radio: Generate a check: Build a list box: Generate a Submit button generate a refill button live Complete watch single-domain tail 3.2 use PHP to dynamically generate data exchange with the database: form.php generate form Field headers: "?> generate normal text:"?> generate password text:?> generate scrolling text:?> generate a radio:?> Generate a check: "? > Build list box: Network Database ASP Technology PHP technology JSP technology website design "?> Generate Submit Button"?> Generate Refill button "?> Generate form Field tail"?> 3.3 The action form for dynamically generating data exchange with the database using JSP form.jsp Generate form Field headers: Generate normal text: Generate password text: Generate scrolling text: Generate a radio: Generate a check: Build a list box: Generate a Submit button generate a refill button to generate a form field tail

4. design MySQL database to store interactive data for business Web 4.1 start the MySQL database server (MySQL installation and ODBC driver installation and settings refer to related books) can be used under the NT5.0 to start the service method NET command/Command Window type Mysqld-shareware method, start the MySQL database server, start the database server, at the d:\mysql\bin> prompt type mysql-h 127.0.0.1-u root can appear MySQL > prompts, starting from here to do a variety of operations on the MySQL database. To exit to type Quit/exit, to close the database server, at the d:\mysql\bin> prompt, key mysqladmin-u root shutdown 4.2 to establish the MySQL database in the MySQL database prompt mysql> Type CREATE DATABASE Tradedb;(or go) 4.2. Set up a MySQL table here, for example, several commonly used data tables in business websites, The main data table and the SQL code to generate the data table are as follows: (Here the data table fields can be actually operated by corresponding to the above form Field objects, and the data tables are unified by TableName) client login Management datasheet CREATE table users (ID int NOT NULL Auto_increment, UserName varchar () NOT NULL, Password varchar () NOT NULL) Customer Information Datasheet CREATE table Usermessage (UserName varchar () not NULL, Email varchar NOT NULL, address varchar (= NOT NULL, Fax varchar NULL, Phone varchar (40) Not NULL, Cerreycard varchar is not NULL customer orders product Datasheet CREATE Table catalog (ProductId int NOT NULL, Name varchar () No T null, price float (6,2) not NULL, Description text null)

5. Design a 3p program that processes form data the ASP program that handles form data form_cl.asp establishes a connection to the database: This uses the direct drive method Set conn = Server.CreateObject ( "ADODB. Connection "); Conn.Open" Driver={mysql};server=localhost;uid=user;pwd=xxxxxx;database=tradedb "gets the data submitted by the form: data1= Request ("PTWBK"); Data2=request ("mmwbk"); Data3=request ("GDWBK") data4=request ("Dxk"); Data5=request ("fxk"); data6= Request ("LBK") uses SQL statements to manipulate the database query data records: Sql= "SELECT * FROM TableName"; set Rs=conn.execute (SQL) "Add data record: sql=" INSERT INTO t Ablename (PTWBK,MMWBK,GDWBK,DXK,FXK,LBK) VALUES (' data1 ', ' data2 ', ' data3 ', ' data4 ', ' data5 ', ' data5 ') "; set rs= Conn.execute (SQL) change a data record: sql= "update tablename set data1=" Request (PTWBK), where id= "num"; set Rs=conn.execute (SQL) Delete In addition to a data record: sql= "delete from tablename where id=" num ", set Rs=conn.execute (SQL) outputs the data results processed by the SQL statement Response.Write"

"Response.Write" for i=0 to Rs. Fields.count-1 Response.Write "" & Rs. Fields (i). Name & "Next Response.Write" while not Rs. EOF Response.Write "" for i=0 to Rs. Fields.count-1 Response.Write "" & Rs. Fields (i). Value & "Next Response.Write" "Rs. MoveNext Wend Response.Write "" Shut down the database: rs.close;conn.close5.2 design a PHP program to process the form data form_cl.php Establish a connection to the database: here PHP MySQL function method (also available with ODBC function method) $conn =odbc_connect ("localhost", "User", "xxxxxx"); Select database: mysql_select_db ("Tradedb", "$conn"); Data received from the form submitted: $data 1= $ptwbk; $data 2= $mmwbk; $data 3= $gdwbk; $data 4= $dxk; $data 5= $fxk; $data 6= $LBK; Use SQL statements to manipulate a database query data records: $sql = "SELECT * FROM tablename"; $result =odbc_do ($conn, $sql); Add data records: $sql = "INSERT INTO tablename (PTWBK,MMWBK,GDWBK,DXK,FXK,LBK) VALUES (' $data 1 ', ' $data 2 ', ' $data 3 ', ' $data 4 ', ' $ Data5 ', ' $data 6 '); $result =odbc_do ($conn, $sql); Change a data record: $sql = "UPDATE tablename set $data 1=ptwbk where Id=num" $result =odbc_do ($conn, $sql); Delete a data record: $sql = "Delete from tablename where id=num"; $result =odbc_do ($conn, $SQL); Output Odbc_result_all ($result, "border=1") of the data result processed by SQL statements; Shutdown database: Odbc_close ($conn); 5.3 Design JSP program that handles form data form_cl.jsp establish a connection to the database: Here the Jdbc-odbc Bridge is used to generate the JavaBean method Create a JavaBean named Conndb.java, and save in the D:/resin1.1.3/doc/web-inf/classes/trade directory, the code is as follows: (limited to the space here is not written according to the standard, and the use of no line, other similar) Package trade; Import java.sql.*; public class Conndb {String url= "jdbc:inetdae:localhost"; String login= "User"; String password = "xxxxxx"; String sdbdriver = "Sun.jdbc.odbc.JdbcOdbcDriver"; String sConnStr = "Jdbc:odbc:Dsnmysql"; Connection conn = null; ResultSet rs = null; Public conndb () {try {class.forname (sdbdriver); Connection conn = drivermanager.getconnection (Url,login,password);} catch (Java.lang.ClassNotFoundException e) {System.err.println ("conndb ():" + e.getmessage ());} Public/resultset/executequery (String/sql)/{rs=null;try{conn=drivermanager.getconnection (SCONNSTR); Statement stmt = Conn.createstatement (); rs = stmt.executequery (SQL); catch (SQLException ex) {System.err.println ("Aq.executequery:" + ex.getmessage ());} REturn rs; Then compile Conndb.java with Javac to generate Conndb.class files with the same directory, add the following tag to the form_cl.jsp file to establish a connection to the database the data submitted by the form is received: String data1= Request.getparameter ("ptwbk"); String Data2=request.getparameter ("MMWBK") string Data3=request.getparameter ("GDWBK") string data4= Request.getparameter ("Dxk") string Data5=request.getparameter ("Fxk") string Data5=request.getparameter ("LBK") Statement to manipulate the database query data records: String sql= "SELECT * from tab Lename"; Connbean.executequery (SQL); Add data record: String sql= "INSERT INTO tablename values (' + data1 +" ', ' "+data2 +" ', ' "+data3 +" ', ' "+ data4+" ' + "', '" + data5 + "', '" + data6+ ' ")"; connbean.executequery (SQL); Change a data record: String sql= "UPDATE tablename set data1= '" + ptwbk + "', data2= '" + MMVBK + "', data3= '" +GDWBK + "' where id= '" + num + "'"; connbean.executequery (SQL) deletes a data record: String sql= "delete from tablename where id= '" +num+ ""; Connbean.executequery (SQL); The data result processed by the SQL statement is output ResultSet rs = connbean.executequery (SQL); while (Rs.next ()) {Out.print ("" +rs.getstring ("ptwbk") + ""); out.print("" + rs.getstring ("MMVBK") + ""); Out.print ("" + rs.getstring ("gdwbk") + ""); Out.print ("" + rs.getstring ("dxk") + ""); Out.print ("" + rs.getstring ("fxk") + ""); Out.print ("" + rs.getstring ("LBK") + " ");} Close database: Rs.close ();

6. Three types of E-commerce Web site Design Technology Overview 6.1 main features: visible below table Design technology run Platform Server Development Program Extensions component ASP Windows series IIS vbscript/jscript/perl ActiveX PHP UNIX Series Novell,windows Apache and many other servers PHP Function JSP UNIX series, novell,windows resin and many other servers Java JavaBean 6.2 Connection Database method: Through the above operation can be seen, this article uses Three kinds of methods of operation MySQL database, ASP adopts direct drive method, PHP uses MySQL function method, JSP uses Jdbc-odbc/javabean method 6.4 operable main database above three kinds of dynamic technology operation database method, Can operate on the Windows platform, such as Access/mssql/foxpro/informix/oracle database, PHP and JSP can operate on the Linux platform database postgres/sybase/oracle, and so on. 6.5 Platform and code versatility the above design method uses the common code way, to PHP and JSP most of the code can run in Windows, but also run on Linux; Considering the many convenient features of MySQL, this article takes this as an example to do some useful work references: 1 Wang Xiaoping. ASP network Development technology. People's post and Telecommunications press, 2000.1 2 Leon atkinson.php core programming. Tsinghua University Press, 2000.4 3 Shi Zhenguo. Java Design Technology for multimedia communication Web pages.



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