0
sundeep.kumar's Avatar, Join Date: Dec 2007
Go4Expert Member
thanks pradeep i actually modified the code as follows
login.pl
Code:
#!C:\perl\bin\perl.exe

# Display script errors.
   use CGI;
   use CGI::Carp qw/fatalsToBrowser warningsToBrowser/;
   use CGI::Session ( '-ip_match' );
   use DBI;
   use DBD::mysql;
   
   $q = new CGI;
       $usr = $q->param('name');
       $pwd = $q->param('password');

	my $db="disease";
	my $host="localhost";
	my $user="root";
	my $password="mysql1234"; 

	#connect to MySQL database
	
	my $dbh = DBI->connect('DBI:mysql:disease;host=localhost','root', 'mysql1234', { RaiseError => 1 } );
	my $query = new CGI;
	
	# matching user input data against database 

	my $sth = $dbh->prepare("select * from user where login_name = '$usr' AND password = '$pwd'")or &dbdie; 
	$sth->execute() or &dbdie; 
	my $result = $sth ->execute();


  if($usr ne '')
  {
   # process the form
      if($result eq 1)
      {
          $session = new CGI::Session();
          print $session->header(-location=>'index.pl');
      }
      else
      {
		print $q->header(-type=>"text/html",-location=>"http://localhost/database3/");
		print "Wrong username/password ";
		print "click here to <a href='http://localhost/cgi-bin/db-cgi/register.cgi'> Register </a>";
      }
   }
  elsif($q->param('action') eq 'logout')
  {
      $session = CGI::Session->load() or die CGI::Session->errstr;
      $session->delete();
      print $session->header(-location=>"http://localhost/database3/");
	  print "Wrong username/password ";
	  print "click here to <a href='http://localhost/cgi-bin/db-cgi/register.cgi'> Register </a>";
  }
  else
  {
  
  print $q->header(-type=>"text/html",-location=>"http://localhost/database3/");
  print "Thank you for visiting Bionteq Website";
  }

>>>>>>>>>>>>>>>>>>>>>>>>>>
and index.pl as follows
Code:
#!C:\perl\bin\perl.exe

# Display script errors.
  use CGI::Carp qw(fatalsToBrowser);
  use CGI;
  use CGI::Carp qw/fatalsToBrowser warningsToBrowser/;
  use CGI::Session ( '-ip_match' );
  
  #print "Content-type: text/html\n\n";
  
  $session = CGI::Session->load();
  $q = new CGI; 	
  
# Begin the page.
  print "Content-type: text/html\n\n";
  
  if($session->is_expired)
  {
      print $q->header(-cache_control=>"no-cache, no-store, must-revalidate");
      print "Your session has expired. Please login again.";
 print "<br/><a href='http://localhost/database/login.html'>Login</a>";
  }
  elsif($session->is_empty)
  {
      print $q->header(-cache_control=>"no-cache, no-store, must-revalidate");
      print "You have not logged in";
  }
  else
  {
      my $url="http://localhost/database3/home_page.html";
	  my $t=1; # time until redirect activates
	  print "<META HTTP-EQUIV=refresh CONTENT=\"$t;URL=$url\">\n";
  }
  
    
# End of script.
now the problem that i am facing is even after login in when i click on home in home_page.html i am getting default.html page (one which has login form).

Please tell me where i am going wrong .. if possible also give me a brief description about it .

Last edited by shabbir; 12Jan2010 at 08:58.. Reason: Code blocks
0
pradeep's Avatar, Join Date: Apr 2005
Team Leader
Please check the HTML file home_page.html which might have some META-refresh tag.