CGI method connection database

xiaoxiao2021-03-05  25

There is no doubt that the most attractive and most complicated and most complicated in the design of today's web program is a web database program. Ping, its complexity is by no means you can think. Let's first take a look at the problems involved in it:

1. The most basic HTML design

2. CGI program writing debugging

3. Network management and customer coordination

4. Database editing

5. Customer / Services System Program

In addition, you have to struggle with your customers from time to time to get their recognition of you. Therefore, a large web database is written, which is the test of overall quality.

The author's self-satisfaction is not fully equipped, but fortunately, I have participated in several Web database development, and I have a preliminary experience. Share this here, it is also a thank you for your summary of this intermittent tutorial.

One database selection

From a general situation, using a web database is often a problem that the data is summarized, indexing, and maintenance. We generally choose the most popular relational database, such as the SQL, WIN95 and NT under the SQL, WIN95 and NT, and the Sybase, UNIX under the NT, MSQL, etc. Of course, Oracle, Filemaker Pro, Paradox, etc. These are all popular SQL databases. SQL provides a standard and solid interface to data management, which is required to be implemented in database languages. Such functions include: creation, inserting data, and data modifications of data objects. For small databases with small data, Access is generally used.

Second interface program

Although we can write a Web's CGI interface directly, it is a work that is huge and troublesome. In order to alleviate the burden of the developer, the database programmer writes many interface programs that can be used directly, cooperate with different databases. Here is some very common interface procedures:

DB2wwww

http://www.software.ibm.com/data/db2/db2wfac2.html

This is a tool for connecting to the IBM DB2 database. In the HTTP server, this tool stores the HTML file and the SQL command as a macro file, and then the DB2WWW will handle these macro files after accepting the browser request.

2. DBCGI

http://www.progress.com/webtools.html

This tool implements connections to the database by built-in SQL statements in an HTML file. Suitable for Progress, Sybase, Oracle, Informix, IngRes, and ODBC. Here is a typical DBCGI program code:

DBCGI TEST </ TITLE> <SQL Init> InformixDir = / usr / informixdirsqlexec = / usr / informix / sqlturbotbconfig = tbconfig </ sql> <SQL Connect Connl> <database = stores> <SQL> <SQL Format>%% [! 8: <H1>% 8D </ h1>%] .... </ SQL> <SQL Query Connl> Selet * from customerOrRorder by Date, City, Zipcode </ SQL> <SQL Disconect CONNL> </ SQL > <SQL Uninit> </ SQL> This tool places the SQL statement in the HTML statement via <SQL> tag and% shift character.</p> <p>3 genera</p> <p>http://gdbdoc.gdb.org/letovsky/genera/general.html</p> <p>This is the gateway of the Sybase database system. It connects to the database by adding a specific statement in a text file.</p> <p>4 WebDBC</p> <p>http://www.ndev.com</p> <p>With Windows NT, you can access all databases compatible with the ODBC. 5 a-xorion</p> <p>http://www.clark.net/infouser/endidc.html</p> <p>He is a CGI gateway that can access most PC databases. It is platform for Windows 3.1 / 95 / NT. The database is MS Access 2.0.</p> <p>Three-programming language</p> <p>What is introduced above is some common interface programs that require the match of Server to work. Of course, if you are a small database program, you don't need to use this complex database interface program. Write into a CGI program with C, Perl, VB, etc., call the database within the CGI program. Although the speed is not very fast, it is definitely very simple.</p> <p>Last example:</p> <p>Finally, I am going to end this tutorial with an example.</p> <p>surroundings:</p> <p>This is a very simple web application. If you want to run this program, you may get some time to configure your own system. In this example, the CGI program is written by Perl5. The background database uses Sybase System 10, Sybperl is used to establish communication between scripts and databases, using other CGI background database interface programs.</p> <p>CGI program:</p> <p><Head> <Title> Conference Registration Procedure </ Title> </ head> <body> <h2> Conference Registration System </ h2> please Fill Out The Following Form. A Registration Packet Will Be Sent To You Immediatel You.note That All <b> Bolad-Faced </ b> fields muse be complected. <hr> <form method = "post" action = "cgi-bin / resgister.pl"> <b> first name: </ b> <input TYPE = "text" name = "c_fname" size = 30> <p> <b> last name: </ b> <input type = "text" name = "c_lname" size = 30> <p> <b> address 1: </ b> <input type = "text" name = "c_add1" size = 30> <p> <b> address 2: </ b> <input type = "text" name = "c_add2" SIZE = 30 > <p> <b> city: </ b> <infut type = "text" name = "c_city" size = 30> <p> <b> state: </ b> <input type = "text" name = "c_state" size = 2> <p> <b> zip: </ b> <input type = "text" name = "c_zip" size = 15> <p> <b> phone: </ b> <input type = "Text" name = "c_phone" size = 15> <p> <b> fax: </ b> <input type = "name =" c_fax "size = 15> <p> <b> email: < / b> <input type = "text" name = "c_email" size = 15> <p> packge: <ul> <li> <input type = "radio" name = "c_packge" VALUGE = "a"> package a <li> <input type = "radio" name = "c_packge" valuge = "b"> package b <li> <input type = "radio" N AME = "</p> <p>c_packge "Valuge =" C "> Package C </ ul> How Did You Hear About The Conference: <UL> <li> <input type =" radio "name =" c_ad "value =" a "> Direct mail <li > <input type = "radio" name = "c_ad" value = "b"> associate <li> <input type = "radio" name = "c_ad" value = "c"> journal <li> <input type = " Radio "Name =" c_ad "value =" d "> other </ ul> <p> <input type =" reset "value =" clear "> <input type =" submit "value =" register "> <p> </ form> <hr> </ body></p> <p>Perl scripts: #! / Usr / local / bin / perlreme "cgi-lib.pl"; & readparse (* input); $ mc_fname = $ input {'c_fname'}; $ mc_lname = $ input {'c_lname'}; MC_ADD1 = $ INPUT {'c_add1'}; $ mc_add2 = $ INPUT {'c_add2'}; $ mc_city = $ INPUT {'c_city'}; $ mc_state = $ int {'c_state'}; $ mc_zip = $ inT {' c_zip '}; $ mc_phone = $ input {' c_phone '}; $ mc_fax = $ input {' c_fax '}; $ mc_email = $ input {' c_email '}; $ mc_package = $ input {' c_package '}; $ mc_ad = $ INPUT {'c_ad'};</p> <p>Print & Printheader;</p> <p>IF (($ MC_FNAME EQ ") || (MC_LNAME EQ") || (MC_ADD1 EQ ") || ($ MC_ADD2 EQ") || (MC_STATE EQ ") || (MC_STATE EQ") || (MC_ZIP EQ "))) {Printf (" <br> "); Printf (", Strong> Your Registration Cannot Be Processed As Is.pleae Make Sure All The Requied Fields Are Filled Properly. </ Strong> ") PRINT "<p>"; Print "pleae use the the <i> back </ i> Button to completion the form./n";} :: Data is Okuse Sybase :: dblib</p> <p>$ dbh = sybase :: dblib-> dblogin ('conf_user', '123', 'db-server', 'reg'); $ dbh-> dbuse ('conference ";</p> <p>$ sqlcmd = "INSERT INTO REG (C_FNAME, C_LANME, C_ADD1, C_ADD2, C_CITY, C_STATE, C_ZIP, C_PHONE, C_FAX, C_EMAIL, C_PACKAGE, C_AD";</p> <p>$ sqlcmd = $ sqlcmd. "VALUES (" $ sqlcmd = $ sqlcmd. '/ "". $ mc_fname. "/", ", $ sqlcmd = $ sqlcmd.' /" "". $ mc_flame. "/", "; $ SQLCMD = $ SQLCMD. '/ "". $ mc_add1. "/", "; $ sqlcmd = $ sqlcmd.' /" "". MC_ADD2. "/", "; $ sqlcmd = $ sqlcmd. '/" " . $ mc_city. "/"; $ sqlcmd = $ sqlcmd. '/ "" ". $ mc_state." / ","; $ sqlcmd = $ sqlcmd.' / "". $ mc_zip. "/", " $ SQLCMD = $ SQLCMD. '/ "". $ mc_phone. "/"; $ sqlcmd = $ sqlcmd.' / "". $ mc_fax. "/"; $ sqlcmd = $ sqlcmd. '/ "" . $ mc_email. "/", "; $ sqlcmd = $ sqlcmd. '/" "". $ mc_package. "/", "; $ sqlcmd = $ sqlcmd.' /" "". $ SQLCMD = $ SQLCMD. '/ "". $ mc_fax. "/", "; $ dbh-> dbcmd ($ sqlcmd." / n "); $ dbh-> dbsqlexec;</p> <p>Print "<strong> Thank you. </ strong> Your registration has been submitted.you should receivers you packet shourtly in the mail."</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-34377.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="34377" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.036</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'FmrfAAIRkzeaLql_2Bws2J5GRK6DZ1zwi5Uhdh_2B1iH6lK6BWr3ZcCDVrFbkzZZMiOnBha_2Bpq4AxVbsQTmC'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>