Solved

cgi with perl or other lang

Posted on 2000-04-14
4
541 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

615 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