Welcome Guest ( Log In | Register)



2 Pages V   1 2 >  
Reply to this topicStart new topic
> [php]password Protect W/o Db, A good php tutorial
maddog39
post Feb 14 2005, 12:30 AM
Post #1


Super Member
*********

Group: Members
Posts: 208
Joined: 27-January 05
From: LI, New York
Member No.: 3,448



Hello all,

I found this script actually on another website. But I modded it and added some things. Heres the code and stuff.

Open a new file in your text editor and paste in this code.
CODE

<?php
{
echo '<form name='pp' method='post' action='check.php'>
Username:<input type='text' name='user' value=''><br>
Password:<input type='password' name='pass' value=''><br>
<input type='submit' value='Login'>
</form>';
}
?>

Name this file login.php

Now open another new file in your text editor and paste in this code.
CODE

<?php
// Change 'YourUsername' to whatever you want.
if ($_POST['user'] == "YourUsername") {
// Change 'YourURL' to the directory to forward to.
echo "<meta http-equiv='refresh' content='0;URL=YourURL'>";
}
else {
header("Location: error.php");
}
// Change 'YourPassword' to whatever you want.
if ($_POST['pass'] == "YourPassword") {
// Change 'YourURL' to the directory to forward to.
echo "<meta http-equiv='refresh' content='0;URL=YourURL'>";
}
else {
header("Location: error.php");
}
?>

Name this file check.php

For the last file, open up another new file in your text editor and paste in this code.
CODE

<?php
echo "I am sorry, you have entered the username or password inccorectly. You are now being redirected.";
echo "<meta http-equiv='refresh' content='2;URL=login.php'>";
?>

Name this file error.php. Then upload these to your server and try them out. Its an easy way to password protect directories on a webserver. biggrin.gif

Demo: CLICK HERE
Deno User: test
Demo Pass: test

This post has been edited by maddog39: Feb 19 2005, 06:59 PM
Go to the top of the page
 
+Quote Post
ill
post Feb 14 2005, 05:45 AM
Post #2


Super Member
*********

Group: Members
Posts: 386
Joined: 10-August 04
From: United States
Member No.: 761



Interesting. I like it, I might put this to use for my "Slave" team. smile.gif
Go to the top of the page
 
+Quote Post
bigboss
post Feb 14 2005, 03:46 PM
Post #3


Newbie [Level 3]
***

Group: Members
Posts: 49
Joined: 13-February 05
Member No.: 3,748



thats interesting thanks for the tip
Go to the top of the page
 
+Quote Post
maddog39
post Feb 14 2005, 07:52 PM
Post #4


Super Member
*********

Group: Members
Posts: 208
Joined: 27-January 05
From: LI, New York
Member No.: 3,448



Your all welcome. biggrin.gif
Go to the top of the page
 
+Quote Post
Taupe
post Feb 15 2005, 03:21 PM
Post #5


Advanced Member
*******

Group: Members
Posts: 119
Joined: 25-October 04
Member No.: 1,937



Don't forget to add <fieldset>s and <label>s in your forms...
Go to the top of the page
 
+Quote Post
maddog39
post Feb 15 2005, 09:34 PM
Post #6


Super Member
*********

Group: Members
Posts: 208
Joined: 27-January 05
From: LI, New York
Member No.: 3,448



What the heck do those do. The script works fine ive tried it and I use it.
Go to the top of the page
 
+Quote Post
Taupe
post Feb 16 2005, 10:18 AM
Post #7


Advanced Member
*******

Group: Members
Posts: 119
Joined: 25-October 04
Member No.: 1,937



Read this article, this one, this explaination., this checklist, this tutorial, this one and thiat one if you still don't know those basic tags...

(And no : the script doesn't work fine : try to validate your page and you'll see...)
Go to the top of the page
 
+Quote Post
maddog39
post Feb 19 2005, 06:00 AM
Post #8


Super Member
*********

Group: Members
Posts: 208
Joined: 27-January 05
From: LI, New York
Member No.: 3,448



Looky here. I setup a demo for you guys, the user is test and the pass is test. Try it it works. Plus I dont know what you mean by vailidate it. Anyway I am going to clean up the code a little bit.
Go to the top of the page
 
+Quote Post
EricDrinkard
post Feb 19 2005, 06:16 AM
Post #9


**removed link**
********

Group: Members
Posts: 180
Joined: 21-July 04
From: I Don't Know
Member No.: 162



Hey this might be what I am loking for......
Thank fo a while I have ben lookig for a logi system tha wa simple but not stupid.




Thanks
Eric Drinkad