PirateBagel Posted April 10, 2007 Share Posted April 10, 2007 I only need to secure one page, and security isnt that big of an issue. All im looking for is a username/password prompt (I only need one logon) I don't want to deal with mySQL databases, adding, tracking, blah blah blah - Just a login. I've been searching and everything I find isnt what I'm looking for, I know this cannot be too much code. Thanks, Adam Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted April 10, 2007 Share Posted April 10, 2007 Does it have to be like a javascript pop up window login box? You can easily create one by just storing the login and password in variable and checking against the inserted data to make sure it matches. Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted April 10, 2007 Share Posted April 10, 2007 if you don't want to deal with a database, the only way to authenticate a user is on the server level. this should be easy to implement, altho it would be more difficult if you are using a hosting company to host your site, but still do-able. Quote Link to comment Share on other sites More sharing options...
PirateBagel Posted April 10, 2007 Author Share Posted April 10, 2007 I found a good prebuilt code from Steve Dawson http://www.stevedawson.com/article0014.php It does what I'm looking for, thanks though. Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted April 10, 2007 Share Posted April 10, 2007 ...or you can hard-code the passwords in your script. <?php $passwords = array('dirka', 'poop', 'admin', 'reefer'); $bool = false; if(isset($_POST)){ foreach($passwords as $password){ if($_POST['password'] == $password){ $bool = true; } } if($bool = true){ header(Location: www.yoursite.com/successfulLogin.php); } else{ echo "You have not entered the correct password. Please try again."; } } echo " <form action=\"\" method=\"post\"> enter password:<input type=\"password\" name=\"password\"> <input type=\"submit\" value=\"Submit\"> </form> "; ?> Quote Link to comment Share on other sites More sharing options...
per1os Posted April 10, 2007 Share Posted April 10, 2007 The only problem with boo's is that one, anyone can access successful login. two, it will always send them to that page due to $bool = true, it is assigning it to true which is always true =) That script you posted is a good one. Another option would be .htaccess with .htpasswd, but if that script works for you, great. =) Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted April 10, 2007 Share Posted April 10, 2007 The only problem with boo's is that one, anyone can access successful login. two, it will always send them to that page due to $bool = true, it is assigning it to true which is always true =) That script you posted is a good one. Another option would be .htaccess with .htpasswd, but if that script works for you, great. =) say what now? EDIT: OH did you mean this part? if($bool == true){ Quote Link to comment Share on other sites More sharing options...
TEENFRONT Posted April 10, 2007 Share Posted April 10, 2007 I know this is solved, but if you have a server running Cpanel, you can use the Password protect directories tool. This adds a .htaccess username and password facility to directories. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.