1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

validation from atext file and adding to text file

Discussion in 'Perl' started by Devashish_saha, May 31, 2005.

  1. Devashish_saha

    Devashish_saha New Member

    Joined:
    May 31, 2005
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I am new to perl . i have been given ap project to validation username and pssword form text file and store login date and login time to a text file . Ihave written a below code in which i have done the validation and i can show the logodte and time in the browser
    but i canot the information in atext file pls help me out



    #!/usr/bin/perl

    use CGI;
    $var=new CGI;
    $username=$var->param("username");
    $password=$var->param("password");




    print "Content-type: text/html\n\n";



    if (-e "/httpd/GuestDB/Emp.txt"){
    open (example, "/httpd/GuestDB/Emp.txt") || die ("Could not open file <br> $!");

    @text = <example>;


    $flag = 0;
    foreach $file1 (@text)

    {


    my ($data1, $data2)=split(":",$file1);

    sub trim
    {
    my $string = shift;
    for ($string)
    {
    s/^\s+//;
    s/\s+$//;
    }
    return $string;

    }

    $user = trim($data1);
    $pass = trim($data2);


    if(($user eq $username) && ($pass eq $password))
    {

    $flag=1;

    break;
    }



    }





    my $now = localtime;


    if ($flag eq 1)


    {
    print $username,$now;
    }






    # open (example1, ">/httpd/GuestDB/Log.txt") || die ("Could not open file $!");
    # @db_lines1 = <example1>;




    else {
    print "Error ...";
    }



    }
    close (example);
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,276
    Likes Received:
    364
    Trophy Points:
    83
    can you explain what you mean by the above line.
     

Share This Page