Passwords

Web hosting discussion, programming, and shared and dedicated servers.
9 posts Page 1 of 1
by terry2 » Thu Aug 11, 2011 11:48 am
I have a domain on Sonic.net and want to establish a pasword for all folks who visit. A single password for everybody is quite adequate - I do not want to establish a list of user names, each with their own password.
Is there a relatively easy way to set a password for an entire domain?
by williamt » Thu Aug 11, 2011 1:24 pm
Sr. Systems Administrator @ sonic.net
by terry2 » Thu Aug 11, 2011 8:43 pm
I have read this page carefully. The command 'require user' seems to only talk about how I can set a password for a single person, namely me. I could use the same command to create a list of user names and individual passwords, but that's not what I want. All I want is a single password that any visitor can enter. I see there is a command 'require valid-user' that might apply here, but I'm not sure how to use it. I *thought* that putting a password on a web domain would be easy - but it seems to be a large undertaking. ANy suggestions?
by williamt » Thu Aug 11, 2011 10:55 pm
There has to be a user associated with a password. If you want to tell the user what the username is
you could always use "AuthName" for that purpose. The string after AuthName is displayed on the password
popup. So something like:

Code: Select all

AuthUserFile /home/WWW_pages/loginname/password-dir/.htpasswd
AuthGroupFile /dev/null
AuthName "Use username 'Guest'"
AuthType Basic

<Limit GET>
require user Guest
</Limit>

That would tell them what username to use.
This is the simplest way to password protect a portion of your website without having to write code to do so.
Sr. Systems Administrator @ sonic.net
by terry2 » Mon Aug 15, 2011 11:50 am
Many thanks for the help!
Now ... do I need to provide two boxes in the html code - one to display 'User Name' and one to display 'Password', or is all of that already - somehow - handled? The 'login' page is already writen, where a visitor is given a choice between entering a password or going to PayPal to buy a subscription. I'm just wondering how much of that page I need to change in order to have 'User Name' displayed. Is there some clever way to have 'User Name' always equal "Guest" witout having to display it? That would make it easier for the visitor. Thanks again!
(P.S. if you want to see my 'Login' page, it is at http://c2cwtnd.net )
by williamt » Mon Aug 15, 2011 12:07 pm
If you do it that way you would have to write php/perl code to handle your login I believe.
Just provide a members html link that links to c2wtnd.net/members and put the .htaccess file in the members
directory. When someone tries to go to the members directory they will get a popup message prompting them for a username and password.

Alternatively I think you might be able to write your members link like: http://Guest@c2wtnd.net/members and that might pre-fill the username for you. You would have to test though.
Sr. Systems Administrator @ sonic.net
by dman » Sat Sep 03, 2011 4:42 pm
If you're still having trouble, these PHP code snippets should help, if you replace my_password with whatever you'd like the password to be then it should do what you want. Put the first code snipped on the same page as the login form, and the second code snippet on any page that you want to enforce authentication on. You will need to change the extension on these pages from html to php so the webserver knows what to do with them. Hope this helps, cheers!

<?php
session_start();
if ($_POST['login'] == "my_password"){ #change my_password with whatever you'd like your password to be
$_SESSION['login'] = TRUE;
}
?>

<?php
session_start();
if(!$_SESSION['login']){
header("Location: http://c2cwtnd.net/");
}
?>
by dman » Sat Sep 03, 2011 4:43 pm
dman wrote: <?php
session_start();
if ($_POST['login'] == "my_password"){ #change my_password with whatever you'd like your password to be
$_SESSION['login'] = TRUE;
}
?>

<?php
session_start();
if(!$_SESSION['login']){
header("Location: http://c2cwtnd.net/");
}
?>
This isn't really the most secure way to enable password authentication, but it's quick and dirty and should work.
by tnd_travels » Fri Sep 09, 2011 5:36 pm
Thanks you very much for the latest posting. I will give that a try - if my current attempts don't pan out.
I know nothing about php/perl code, so something "simple" is what I'm looking for. Thanks again.
9 posts Page 1 of 1

Who is online

In total there are 38 users online :: 0 registered, 0 hidden and 38 guests (based on users active over the past 5 minutes)
Most users ever online was 999 on Mon May 10, 2021 1:02 am

Users browsing this forum: No registered users and 38 guests