Solved

cgi with perl or other lang

Posted on 2000-04-14
4
519 Views
Last Modified: 2013-12-25
which is the best in creating the CGI is it using perl or other language such as delphi, V c++,and etc
0
Comment
Question by:eddyhalim
  • 2
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
makerp earned 20 total points
ID: 2715280
the fastest lang to use is perl and its also the easyist. its got loads of support for cgi

doing cgi in c/c++ involves much more work than using perl.  

heres a simple perl example

#
# very simple serach engine demo using DBI. the data base is a simple
# access db with one table called sites. each row has a url column and
# keyword column

use CGI;
use DBI;

# dsn i have created in odbc contol panel
$DSN = "test_db";
# dbd driver to use
$DRIVER = "ODBC";

$query = new CGI;

print $query->header();

# if we have no params then display the form
if(!$query->param())
{
     print("
           <B>Enter a keyword to search ON : </B>
           <FORM ACTION=search_engine.pl METHOD=POST>
               <INPUT TYPE=TEXT NAME=search>
               <INPUT TYPE=SUBMIT VALUE=Search>
           </FORM>
          ");    
}
# else they have entered a keyword so lets search and display some results
else
{
     # open a connection to the database
     $dbh = DBI->connect('dbi:'.$DRIVER.':'.$DSN,undef,undef) || die("Connection error : ".$DBI::errstr);          
     # create a stmt
     $sth = $dbh->prepare("SELECT * FROM sites WHERE keyword = '".$query->param('search')."'") || die("Stmt error : ".$dbh->errstr);
     #exe it
     $sth->execute() || die("Stmt error : ".$dbh->errstr);
     print("RESULTS are : <BR><HR><TABLE BORDER=1><TR><TH>URL's</TH></TR>");
     while($dat = $sth->fetchrow_hashref())
     {
          print("<TR><TD>".$dat->{'url'}."</TD></TR>")
     }
     print("</TABLE><BR><A HREF=search_engine.pl>Search Again</A>");
     $sth->finish();
}
0
 

Author Comment

by:eddyhalim
ID: 2718625
Thanks your answer very clear, but how about ASP?
0
 
LVL 10

Expert Comment

by:makerp
ID: 2722110
asp is easy to.. about the same amount of code as perl to get things done. in my opinion perl is a bit more powerfull. as its a full blown language wereas asp is just for the web.

asp uses vbscript as its programming language. (you can also use perlscript or javacsript but i would'nt).. asp is mainly for nt's iis server but there are facilities avalible to run asp on apache but these have a cost !!

heres an asp example

<%
Set Con = Server.CreateObject("ADODB.Connection")
Con.Open "test_db","",""
IF(Request("update") = "")THEN
Set rs = con.Execute("SELECT * FROM RMA_ASSIGNMENT WHERE ACTIVE = No")
%>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>RMA</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<meta name="Microsoft Theme" content="none">
<meta name="Microsoft Border" content="tl, default">
</head>
<body>

<form ACTION="<%=Request.ServerVariables("SCRIPT_NAME")%>" METHOD="POST">
  <input type="hidden" name="update" value="X"><table border="1" cellspacing="1" width="174"
  height="48" bordercolor="#C0C0C0" style="border: medium ridge rgb(192,192,192)">
    <tr>
      <th width="78" align="center" height="17">RMA</th>
      <td width="84" align="center" height="17">Activate</td>
<%
DO UNTIL rs.EOF
%>
    </tr>
    <tr>
      <td width="78" align="center" height="19"><%=rs("RMA")%>
</td>
      <td width="84" align="center" height="19"><div align="center"><center><p><input
      TYPE="CHECKBOX" NAME="<%=rs("RMA")%>" VALUE="Yes"></td>
    </tr>
<%
rs.MoveNext
LOOP
%>
  </table>
  <div align="center"><center><p><input TYPE="SUBMIT" VALUE="Refresh"> <%
ELSE
FOR EACH field IN Request.Form
IF(field <> "")THEN
con.Execute("UPDATE RMA_ASSIGNMENT SET ACTIVE = Yes WHERE RMA = '"&field&"'")
END IF
NEXT
Response.Redirect(Request.ServerVariables("SCRIPT_NAME"))
END IF
%> </p>
  </center></div>
</form>

<p align="center">&nbsp;
</body>
</html>

0
 

Author Comment

by:eddyhalim
ID: 2729757
thanks for your answer
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question