Solved

cgi with perl or other lang

Posted on 2000-04-14
4
510 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In this tutorial I will aim to show you how simple is making a small application in WhizBase, how to add, remove and update data in the DB. I will make a small address book application where you can add, browse, update and remove addresses. I wi…
Ever wondered how to display how many visitors you have online. In this tutorial I will show you an easy but effective way to display the number of online visitors in WhizBase. In this article I assume you have read my previous articles and know …
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…
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now