Help With CGI Scripts and .htaccess

Hi everyone, I need help with writing a script that does the following:

a client/user goes onto my website, hits a link, it would pop up either

  1. user name and password
  2. password and directory name

and then after they enter the required info, it would take them to their own folder. So If I use Temp as a user and test as a password, it would go directly to temp folder. What is the easiest way to go about this? I have tried using .htaccess but that doesn't re-direct them to a particular folder, it would give access to a folder they click on. Help me out guys, and thanks. You guys are the greatest.

You can give each user a folder and use .htaccess in that folder. For example, if the user is joe you might just create a joe directory and when they go to website/joe they will get the .htaccess generated BASIC AUTH. This is the easiest way.

Hi, would you know how to program something in html that has a box which after they enter whatever number xxxx in that box, writes it into the address box of the browser or links them...such as www.test.com/reports/xxxx

www.test.com/reports

-------------------------
|                             |
| Enter Group #     | 
|       ________      |
|      |__xxxx__|     |
|                             |     
|                             |      
-------------------------
           |
           |
           |

www.test.com/reports/xxxx

thanks.

added code tags for readability --oombera

You might be able to do with with a script that does an HTTP Redirect. If I was going to do it, I would try coding in PHP, capture the text, create the URL and send an HTTP redirect to the browser.

i don't know how to code in PHP, would you code it for me if you have the chance, it shouldn't be to hard, right? thanks if you can do it for me.

OK! You can use .htacces and .htpasswd...

Example your web folder is /home/your_name/html

First you need creat .htpasswd

[binhnx2000@localhost /]# htpasswd -c ./users binhnx2000
New password: pass
Re-type new password: pass
Adding password for user binhnx2000

Have a file is name "user" was creat. It save your password was crypt. You change name to .htpasswd

Now! you need creat .htaccess with content:

AuthName "Restric Area"
AuthType Basic
AuthUserFile /home/your_name/html

require user binhnx2000

# If you use Apache Server, let's add line in file
# To restric down file .htaccess and .htpasswd from Server

<files .htaccess>
Order allow,deny
Deny from all
</files>

<files .htpasswd>
Order allow,deny
Deny from all
</files>

Now! You need set CHMOD is 644 for .htacess and .htpasswd = = > After up 2 file to /home/your_name/html.

You have a message need password and username.

Good Luck

With all Apache Version (have version Windows). You can use .htaccess and .htpasswd.

You need use this code to Crypt your passwd and creat .htaccess

...
$encpass = &encrypt($password);
...
sub encrypt {
my($plain) = @_;
my(@salt);
@salt = ('a'..'z', 'A'..'Z', '0'..'9', '.', '/');
srand(time() ^ ($$ + ($$ << 15)) );
return crypt($plain, $salt[int(rand(@salt))] . $salt[int(rand(@salt))] );
}

After crypt your password. You need creat .htpasswd with content:

Your_user:JNSQVx3F3/n0c = = > Your pass after crypt

Okies