473,395 Members | 2,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to get HTML output using perl/CGI ?

147 100+
Hi,
When i run the program in web server, getting the only output Content-type: text/html . Not displaying anything else. I don't know, whats a problem ? Please check my code.

Expand|Select|Wrap|Line Numbers
  1. #!c:/perl/bin/perl
  2. use CGI qw(:all);
  3. $login=uc(param('uid'));
  4. $passwd=param('pwd');
  5.  
  6.  
  7.  
  8. $kid = time;
  9. $cookie = cookie(-name=>'logtime',
  10.         -value=>$kid,
  11.         -path=>'/cgi-bin/');
  12.  
  13.  
  14.  
  15. if ($login eq "" || $passwd eq "")
  16. {
  17.     print "Content-type: text/html\n\n";
  18.     print "<body bgcolor=\"#ffcccc\">";
  19.     print "<h2>Please enter your userid and password</h2>";
  20.     print "<hr>";
  21. }
  22. else
  23. {
  24.  
  25.     use DBI;
  26.     my $dbh = DBI->connect("DBI:ODBC:sample","aaaa","test")
  27.             or die "Can not connect: $DBI::errstr\n"; 
  28.         $sth = $dbh->prepare("select rollno,passwd from stuacmst where rollno=\'$login\' ") or die "Can not prepare SQL statement: $DBI::errstr\n"; 
  29.         $sth->execute or die "Can not execute SQL statement: $DBI::errstr\n";
  30.         @ary = $sth->fetchrow_array();
  31.         while(substr($ary[1],length($ary[1]) - 1,1) eq ' '){ $ary[1] = substr($ary[1],0,length($ary[1])-2)};
  32.         if ($passwd eq $ary[1])
  33.         {
  34.                 $sth = $dbh->prepare("update stuacmst set kid = ? where rollno = ?") or die "Can not prepare SQL statement: $DBI::errstr\n"; 
  35.                 $sth->execute($kid,$login) or die "Can not execute SQL statement: $DBI::errstr\n"; 
  36.                 print header(-cookie=>$cookie);
  37.     print "Content-type: text/html\n\n";
  38.  
  39.                 print "<HTML>";
  40.                 print "<HEAD>";
  41.                 print "<TITLE>Student page</TITLE>";
  42.                 print "</HEAD>";
  43. print "<FRAMESET ROWS='21,78'>";
  44. print "<FRAME SRC=/cgi-bin/auth/header.cgi>";
  45.                 print "<FRAMESET COLS='170,*'>";
  46.                 print "<FRAME SRC=/cgi-bin/auth/studopts.cgi?rollno=$login>";
  47.                 print "<FRAME SRC=/cgi-bin/auth/ssesschk.cgi?sid=1 name=workwind>";
  48.                 print "</FRAMESET>";
  49. print "</FRAMESET>";
  50.                 print "</HTML>";
  51.  
  52.         }  #Frames are not displaying in the browser."header.cgi" contains only print "<img src=/icons/header.jpg height=100px>";[/b]
  53.  
  54.         else
  55.         {
  56.                 print "Content-type: text/html\n\n";
  57.                 print "<body bgcolor=\"#ffcccc\">";
  58.                 print "<h2>Invalid Attempt!</h2>\n";
  59.                 print "<hr>";
  60.         }
  61.     $dbh->disconnect;
  62. }
  63.  
  64.  

My output in browser
Content-type: text/html
Feb 10 '11 #1
1 2503
numberwhun
3,509 Expert Mod 2GB
For development purposes, you may want to install the CGI::Carp module and put the following in your Perl script:

Expand|Select|Wrap|Line Numbers
  1. use CGI::Carp qw(fatalsToBrowser);
  2.  
That will print errors to your browser and may reveal your issue (possibly).

Regards,

Jeff
Feb 10 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Sam | last post by:
I would like to store html templates in a database. By using perl I would like to retrive the template ask the user to fill the template and store the whole file is template + the user data in a...
1
by: Mark | last post by:
I am creating a search engine that will scan pages on my Web site. I do not want any false-positive hits, being defined as any match that does not appear on the page using a Web browser. I am...
0
by: supern | last post by:
#!c:/perl/bin/perl.exe $basedir="c:/program files/apache software foundation/apache2.2/cgi-bin"; $datafile="regstr.txt"; $name=$in{'login'}; $passwd=$in{'passwd'}; open(FH1,"+>>regstr.txt");...
1
by: jonathan184 | last post by:
Hi I am trying to login a JMS admin tool and execute JMS commands and using perl windows to do this. This is the e.g of connection string they said to use when trying to connec to jms ****connect ...
3
by: fox | last post by:
I need to extract patterns from a line in a web page and these patterns sometimes show up twice in the same line so using grep with the pattern only grabs one. Exaple is I need <td width="30%"...
1
by: norma | last post by:
How can i make refresh of a HTML page using Perl? At this moment i am using "<META HTTP-EQUIV='REFRESH' CONTENT='900;URL= ....... " buth i want to refresh the htlm page every 15 minutes using de...
5
by: moddster | last post by:
Hi Guys. I am a newbie to perl and need some help with a problem. PROBLEM: I have to parse an HTML file and get rid of all the HTML tags and count the number of sumbissions a person has through...
2
by: prajil | last post by:
Hi, Could anyone point how can i override output redirection using perl. i.e. command > file 2>&1 will redirect both output and error of command to file I need to print a message to...
2
by: mahalakshmiDevi | last post by:
I am automating the testing of an web application. The application consist of HTML table with the list of items. I wanted to click on particular item of the table. I have provided the source code of...
1
by: shivsa | last post by:
Hi Experts, I have a simple Perl code, in this, I have a Perl variable , say $original = '<html>..........................................................................<html>' in between...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.