Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

cgi with perl or other lang

Posted on 2000-04-14
4
Medium Priority
?
544 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 80 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

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

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

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

688 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