Results 1 to 9 of 9

Thread: Simple Password Access in CGI

  1. #1

    Thread Starter
    Hyperactive Member Zaphod64831's Avatar
    Join Date
    Mar 2000
    Posts
    268

    Simple Password Access in CGI

    Can anyone tell me how it's done? I'm completely new to CGI so a long spiel would be most helpful
    Email: [email protected]

    Home Page: www.olemac.net/~hutch

    I'm bored, VERY bored, and I got bored with my sig. So I changed it to this.

  2. #2
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    what are you talking about?

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

  3. #3

    Thread Starter
    Hyperactive Member Zaphod64831's Avatar
    Join Date
    Mar 2000
    Posts
    268
    Someone goes to a site, the first thing they see is a password access screen. They type in a password and if it's correct they are redirected to another page.

    Sorry about that, I tend to be too vague in my descriptions...
    Last edited by Zaphod64831; Oct 17th, 2001 at 08:34 PM.
    Email: [email protected]

    Home Page: www.olemac.net/~hutch

    I'm bored, VERY bored, and I got bored with my sig. So I changed it to this.

  4. #4
    denniswrenn
    Guest
    Code:
    #!/usr/bin/perl
    print "Content-type: text/html\n\n\n";
    require("inc.cgi");
    open(FILE, ">>$tfname");
    
    sub GetFormInput {
    
            (*fval) = @_ if @_ ;
    
            local ($buf);
            if ($ENV{'REQUEST_METHOD'} eq 'POST') {
                    read(STDIN,$buf,$ENV{'CONTENT_LENGTH'});
            }
            else {
                    $buf=$ENV{'QUERY_STRING'};
            }
            if ($buf eq "") {
                            return 0 ;
                    }
            else {
                    @fval=split(/&/,$buf);
                    $i = 0;
                    foreach $i (0 .. $#fval){
                            ($name,$val)=split (/=/,$fval[$i],2);
                            $val=~tr/+/ /;
                            $val=~ s/%(..)/pack("c",hex($1))/ge;
                            $name=~tr/+/ /;
                            $name=~ s/%(..)/pack("c",hex($1))/ge;
    
                            if (!defined($field{$name})) {
                                    $field{$name}=$val;
                            }
                            else {
                                    $field{$name} .= ",$val";
                                    
                                    #if you want multi-selects to goto into an array change to:
                                    #$field{$name} .= "\0$val";
                            }
    
    			if($i eq 0) {
    				print FILE "\"$val\"";
    			} else {
                   	   		print FILE ",\"$val\"";
                   	   	}
                       }
                       print FILE "\n";
                    }
                    close(FILE);
    return 1;
    }
    
    &GetFormInput;
    
    if($field{"pass"} eq "mypass" && $field{"user"} eq "username"){
    print "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=urltoredirectto\">";
    } else {
    print "Wrong username or password";
    }
    I haven't tried this yet, but it should work.

    -Dennis

  5. #5

    Thread Starter
    Hyperactive Member Zaphod64831's Avatar
    Join Date
    Mar 2000
    Posts
    268
    Thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you
    Email: [email protected]

    Home Page: www.olemac.net/~hutch

    I'm bored, VERY bored, and I got bored with my sig. So I changed it to this.

  6. #6

    Thread Starter
    Hyperactive Member Zaphod64831's Avatar
    Join Date
    Mar 2000
    Posts
    268
    It didn't work...
    Email: [email protected]

    Home Page: www.olemac.net/~hutch

    I'm bored, VERY bored, and I got bored with my sig. So I changed it to this.

  7. #7
    denniswrenn
    Guest
    Code:
    #!/usr/bin/perl
    print "Content-type: text/html\n\n\n";
    sub GetFormInput {
    
            (*fval) = @_ if @_ ;
    
            local ($buf);
            if ($ENV{'REQUEST_METHOD'} eq 'POST') {
                    read(STDIN,$buf,$ENV{'CONTENT_LENGTH'});
            }
            else {
                    $buf=$ENV{'QUERY_STRING'};
            }
            if ($buf eq "") {
                            return 0 ;
                    }
            else {
                    @fval=split(/&/,$buf);
                    foreach $i (0 .. $#fval){
                            ($name,$val)=split (/=/,$fval[$i],2);
                            $val=~tr/+/ /;
                            $val=~ s/%(..)/pack("c",hex($1))/ge;
                            $name=~tr/+/ /;
                            $name=~ s/%(..)/pack("c",hex($1))/ge;
    
                            if (!defined($field{$name})) {
                                    $field{$name}=$val;
                            }
                            else {
                                    $field{$name} .= ",$val";
                                    
                                    #if you want multi-selects to goto into an array change to:
                                    #$field{$name} .= "\0$val";
                            }
    
    
                       }
                    }
    return 1;
    }
    
    &GetFormInput;
    
    if($field{"pass"} eq "mypass" && $field{"user"} eq "username"){
    print "<META HTTP-EQUIV=\"refresh\" CONTENT=0; URL=http://www.olemac.net\">";
    } else {
    print "Wrong username or password";
    }
    try that.

  8. #8

    Thread Starter
    Hyperactive Member Zaphod64831's Avatar
    Join Date
    Mar 2000
    Posts
    268
    It still doesn't work
    Email: [email protected]

    Home Page: www.olemac.net/~hutch

    I'm bored, VERY bored, and I got bored with my sig. So I changed it to this.

  9. #9

    Thread Starter
    Hyperactive Member Zaphod64831's Avatar
    Join Date
    Mar 2000
    Posts
    268
    BTW I finally saw blazing saddles yesterday on comedy central, that scene was hilarious
    Email: [email protected]

    Home Page: www.olemac.net/~hutch

    I'm bored, VERY bored, and I got bored with my sig. So I changed it to this.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width