Solved

cgi with perl or other lang

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Change the background and font colors in Notepad++ 5 206
Permission on folders 6 35
Find unused columns in a table 12 97
global Variable - 2 functions in powershell 1 44
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 …
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
The viewer will learn how to dynamically set the form action using jQuery.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

752 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