here its is nick
hi nick,
its so nice of you to manage time for me.. heres the script--
The Main Script
#!/usr/bin/perl
use CGI;
use CGI::Carp qw/fatalsToBrowser warningsToBrowser/;
use DBI;
use Digest::MD5 qw(md5 md5_hex md5_base64);
my $query = new CGI;
print $query->header();
warningsToBrowser(1);
print $query->start_html(-title=>'LOGIN PAGE');
$db="administrative";
$host="192.168.0.142";
$user="root";
$password=undef;
if(($query->request_method() eq "POST") && ($query->param("user") ne '') && ($query->param("password") ne ''))
{
$chkuser=$query->param("user");
$chkpassword=$query->param("password");
$md5password = md5_hex($chkpassword);
$dbh = DBI->connect("DBI:mysql:database=$db:host=$host", $user, $password) or die "Can't connect to database:$DBI::errstr\n";
$qry = $dbh->prepare("SELECT password FROM new_user where emp_name='$chkuser'");
$qry->execute;
@row=$qry->fetchrow_array;
$pass=$row[0];
if ($md5password eq $pass)
{
print "<p> You have successfully logged in $chkuser!<p>";
print "<html>";
print "<FORM METHOD='POST' ACTION='view_profile.pl?$chkuser'>"; ##---->>IS THIS OK??
print "<input type='submit' name='submit' value='View Profile'>";
print "</FORM>";
print "<FORM METHOD='POST' ACTION='update_profile.pl'>";
print "<input type='submit' name='submit' value='Update Profile'>";
print "</FORM>";
print "</html>";
$dbh->disconnect;
print $query->end_html();
}
else
{
print "<HEAD> Username or Password Incorrect!</HEAD>";
print "<a href='login_main.pl'>Please Try Again</a>";
$dbh->disconnect;
print $query->end_html();
}
}
else
{
#print "Content-type: text/html\n\n";
#print <<EOF;
print "<HTML>";
print "<BODY>";
print "<FORM METHOD='POST' ACTION='login_main.pl'>";
print "<p>Username:</p>";
print "<input type='text' name='user'><br>";
print "<p>Password:</p>";
print "<input type='password' name='password'><br>";
print "<input type='submit' value='submit'><br>";
print "</FORM>";
print "</BODY>";
print "</HTML>";
#EOF
#print $query->end_html();
}
view_profile.pl
#!/usr/bin/perl
use CGI;
use CGI::Carp qw/fatalsToBrowser warningsToBrowser/;
use DBI;
my $query = new CGI;
print $query->header();
warningsToBrowser(1);
print $query->start_html(-title=>'View Profile');
$db="administrative";
$host="192.168.0.142";
$user="root";
$password=undef;
$dbh = DBI->connect("DBI:mysql:database=$db:host=$host", $user, $password) or die "Can't connect to database:$DBI::errstr\n";
$qry = $dbh->prepare("SELECT emp_id, emp_name, permanent_address, dob, permanent_phone FROM new_user where emp_name='$chkuser'");##-->>IS THIS OK??
$qry->execute;
@row=$qry->fetchrow_array;
print "Content-type: text/html\n\n";
print "<hr>";
print "<p>Employee ID is : @row[0]</p><br>";
print "<p>Employee Name is : @row[1]</p><br>";
print "<p>Employee Address is : @row[2]</p><br>";
print "<p>Employee's Date of Birth is : @row[3]</p><br>";
print "<p>Employee's Phone No. is : @row[4]</p><br>";
print "<hr>";
$dbh->disconnect;
print $query->end_html();
the above combination of scripts is not showing the desired output. Where am i wrong??i hope u got an idea of wt i want from the scripts.. I want to pass the username as an argument to the next script so that it shows the profile of that user.Please ask for any clarifications
Thank You
naveen
Subject
Written By
Posted
here its is nick
May 02, 2005 06:08AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.