It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming PHP and MySQL Forum

Creating a Login/Logout

Moderator: Malcolm

Creating a Login/Logout

Postby TUnit on Tue Dec 14, 2004 8:49 am

Hello All,

I'm trying to do a login/logout area of the site so users can access certain areas. There will only be one username and password. What would be the best way to set that up? Thanks a lot!
User avatar
TUnit
 
Posts: 40
Joined: Wed Dec 08, 2004 4:26 pm
Location: South Dakota

Postby Malcolm on Tue Dec 14, 2004 1:44 pm

If you're on an Apache or IIS server you can easily setup password protected areas on the site, its faster and just as secure as a PHP/MySQL option and will take less time, unless you're looking to have a large or growing userbase.
Image
User avatar
Malcolm
100+ Club
 
Posts: 198
Joined: Thu Oct 07, 2004 9:53 pm
Location: Ontario, Canada

Postby webmaster on Tue Dec 14, 2004 2:03 pm

A fast and easy way:

Code: Select all
<?
if(isset($_POST['B1'])) {

   $name = $_POST['name'];
   $pass = $_POST['pass'];

   if($name == "TUnit" && $pass == "123") {
      echo "THE WHOLE SITE HERE";
   }
}
?>
<form method="POST" action="<? $PHP_SELF ?>">
Username:<br/>
<input type="text" name="name"><p/>
Password:<br/>
<input type="password" name="pass"><p/>
<input type="submit" name="B1" value="LOGIN">


I haven't tested the code yet, but you get the idea.
Make sure to check out our TNX Review and Link Vault Review
User avatar
webmaster
Site Admin
 
Posts: 2695
Joined: Tue Aug 17, 2004 1:07 pm
Location: Sweden

Postby Malcolm on Tue Dec 14, 2004 2:15 pm

Thats just really bad...
Image
User avatar
Malcolm
100+ Club
 
Posts: 198
Joined: Thu Oct 07, 2004 9:53 pm
Location: Ontario, Canada

Postby TUnit on Tue Dec 14, 2004 2:38 pm

awesome, thanks for the help!
User avatar
TUnit
 
Posts: 40
Joined: Wed Dec 08, 2004 4:26 pm
Location: South Dakota

Postby webmaster on Tue Dec 14, 2004 3:09 pm

Malcolm wrote:Thats just really bad...


But it will work :D

Do you know how it is with the security of a script like that Malcolm?
User avatar
webmaster
Site Admin
 
Posts: 2695
Joined: Tue Aug 17, 2004 1:07 pm
Location: Sweden

Postby Malcolm on Tue Dec 14, 2004 3:41 pm

well, if someone disables the PHP module in your server all your passwords are exposed, that would suck.
Image
User avatar
Malcolm
100+ Club
 
Posts: 198
Joined: Thu Oct 07, 2004 9:53 pm
Location: Ontario, Canada

Postby TUnit on Wed Dec 15, 2004 7:04 pm

Another question. Would there be a similar way to do that with just some kind of script that would work with html. I just need a single username and pass that we give to clients to access our entire site. Thanks for the help.

P.S. - Would the above code that you already posted do the same thing? Thanks.
User avatar
TUnit
 
Posts: 40
Joined: Wed Dec 08, 2004 4:26 pm
Location: South Dakota

Postby Phate on Wed Dec 15, 2004 10:42 pm

You can do this using a Javascript... check this site out:

http://www.dynamicdrive.com/dynamicindex9/password.htm
Web-Developing since '03
Image
User avatar
Phate
500+ Club
 
Posts: 826
Joined: Sun Nov 21, 2004 4:12 am
Location: 127.0.0.1

Postby TUnit on Wed Dec 15, 2004 10:52 pm

Awesome, but the more I think about it. I'm using a single user & pass for each individual login (which will be a lot of pages) is there a way I can set it up where I change the user & pass in one location (perhaps a database) and it reflects to all cooresponding pages? I just don't want to go into huge setups and lengthy code. I'm sure someone can help me out! This forum has been a lot of help!
User avatar
TUnit
 
Posts: 40
Joined: Wed Dec 08, 2004 4:26 pm
Location: South Dakota

Next

Who is online

Users browsing this forum: No registered users and 1 guest