Advertisement

05.28.2007 at 01:20AM PDT, ID: 22597782 | Points: 500
[x]
Attachment Details

Connect to database with web browser

Asked by expertblr in Perl Programming Language

Tags: oracle_home, file, connect, database

Hi,
   Home page is having username and password and submit button in html file... while clicking the submit button its redirecting to next page which is /cgi-bin folder abc.pl file..
  In this file having perl code which is connecting to the database.. and want to show the output again in browser... below is the perl code..
#! /usr/bin/perl

use strict;
use DBI;
use CGI qw/:standard/;
print "Content-type: text/html\n\n";
sub connect(){
print "<html><head>\n";
print "<title>Hello, world!</title></head>\n";
print "<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#FF0000\" vlink=\"#800000\">\n";
print "<h1>Hello, world!</h1>\n";
print "</body></html>\n";

 my $dbh = DBI->connect( 'dbi:Oracle:INDIA','abc','abc'') || die "Database connection not made: $DBI::errstr";

print "<html><head>\n";
print "<title>Hello, world!</title></head>\n";
print "<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#FF0000\" vlink=\"#800000\">\n";
print "<h1>Hello, world!</h1>\n";
print "</body></html>\n";
$dbh->disconnect();
}
print "<html><head>\n";
print "<title>Hello, world!</title></head>\n";
print "<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#FF0000\" vlink=\"#800000\">\n";
print "<h1>Hello, world!</h1>\n";
&connect();
print "<a href=\"../perl/tutorial.html\"><b>Back</b></a> to the Tutorial\n";
print "</body></html>\n";



a)while running as a standalone output mean from the command prompt ..its working fine..and shows the output only three print statements.. after the connect statement  there is having another print statement that wihch is not giving the output.. on command prompt ...also

output from the command prompt :
[root@standby cgi-bin]# perl abc.pl
Content-type: text/html

<html><head>
<title>Hello, world!</title></head>
<body bgcolor="#FFFFFF" text="#000000" link="#FF0000" vlink="#800000">
<h1>Hello, world!</h1>
<html><head>
<title>Hello, world!</title></head>
<body bgcolor="#FFFFFF" text="#000000" link="#FF0000" vlink="#800000">
<h1>Hello, world!</h1>
</body></html>
<html><head>
<title>Hello, world!</title></head>
<body bgcolor="#FFFFFF" text="#000000" link="#FF0000" vlink="#800000">
<h1>Hello, world!</h1>
</body></html>
<a href="../perl/tutorial.html"><b>Back</b></a> to the Tutorial
</body></html>


b)while clicking the submit buton on the first page it redirects to /cgi-bin/abc.pl and its not showing any output.. its displaying a blank page.. and the status bar at the below is showing Done..

Please let me know where is the problem..
Thanks...

Start Free Trial
[+][-]05.28.2007 at 03:08AM PDT, ID: 19166760

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.28.2007 at 01:35PM PDT, ID: 19168962

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.28.2007 at 08:39PM PDT, ID: 19169998

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.28.2007 at 09:05PM PDT, ID: 19170048

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.28.2007 at 10:43PM PDT, ID: 19170303

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.28.2007 at 10:49PM PDT, ID: 19170318

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.28.2007 at 10:56PM PDT, ID: 19170330

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.29.2007 at 07:25AM PDT, ID: 19172453

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32