Zubrag.com
October 21, 2018, 04:39:09 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: 1 2 3 [4] 5
  Print  
Author Topic: Password Protection example  (Read 429285 times)
recoding
Global Moderator
Jr. Member
*****
Posts: 71


WWW
« Reply #42 on: May 29, 2009, 03:51:43 PM »

Is there a way to add a logout button at the page that has been protected and when the user presses it it sends them back to the login page... I know when the session times out this happens but I want the user to be able to do it aswell...

how would this be done?

Include this code wherever you want the logout button to appear:
Code:
<form method="get" action="(enter your php document here).php?logout" /><input type="submit" value="Logout" /></form>

Logged

peaces
Newbie
*
Posts: 2


« Reply #43 on: May 30, 2009, 09:20:00 AM »

Hi recoding,

You seem to really be helping a lot of people with password protect. Thanks!

I just downloaded it and set it up with no issue and it works great in protecting the .php page I need protected.

I have added the script you have given above to a location on the .php page.

I also changed ="(enter your php document here).php? to ="mcleland.php?.

mcleland.php is the name of the protected page. When I click on the logout button, it just returns me back to the mcleland page.

Should I have put something else in for the (enter your php document here)?

Thanks in advance.
Logged
recoding
Global Moderator
Jr. Member
*****
Posts: 71


WWW
« Reply #44 on: May 31, 2009, 08:51:20 AM »

Ah, I put the incorrect link, replace action="mcleland.php?logout" with action="mcleland.php?logout=1" so the code should be (for you):
<form method="get" action="mcleland.php?logout=1" /><input type="submit" value="Logout" /></form>

Now, when a user hits logout, the protect scripts sends them to a separate web address, in the password protect php document you got from here, go to line 60, you should get something like this: define('LOGOUT_URL', 'http://www.example.com/'); just replace http://www.example.com/ with where-ever you would like to send the user.

Yea, the password protect has helped me a lot and I kinda know a lot about it, edited a lot etc, so I would be happy to help others working with it (:


-Dan!

PS on another note, read lines 16 and 17 of the code:
# Add following HTML code to your page where you want to have logout link
# <a href="http://www.example.com/path/to/protected/page.php?logout=1">Logout</a>
Logged

peaces
Newbie
*
Posts: 2


« Reply #45 on: May 31, 2009, 12:25:05 PM »

Thanks so much for the help. I for some reason cannot get the "Submit" button to work. If I just use the Logout text, it works fine. If I add the submit button as you have given it to me I return to the protected page. As soon as I take the submit button out of the line, it works.

Thanks again!
Logged
recoding
Global Moderator
Jr. Member
*****
Posts: 71


WWW
« Reply #46 on: May 31, 2009, 02:00:56 PM »

Ah, I wrote it wrong again, I'm replying to this from my phone, so please forgive me if this does not work this time either, try this code:
<form method="get" action="mcleland.php" /><input type="submit" value="Logout" /><input type="hidden" name="logout" value="1" /></form>
Logged

swami
Newbie
*
Posts: 1


« Reply #47 on: June 03, 2009, 10:10:17 PM »

Hi there...

I have a couple of problems

problem #1
I am having trouble with entering new usernames and passwords other than the two examples that are listed.
  'zubrag' => 'root',
  'admin' => 'adminpass', //added the comma as directed
  'sam' => 'password'       

I cannot use the sam option, but the admin works.  When I changed the admin password to adminpass1, it did not work.

problem #2
In my editor, on the very first line, I posted:  <?php include("/home2/thecentu/public_html/password_protect.php"); ?>
This got rid of the error message, however, I cannot get the login page to reappear.  Did I goof somewhere?

Notes:
The page I want to password protect is html coded and saved as a php document.

Thanks!

Logged
recoding
Global Moderator
Jr. Member
*****
Posts: 71


WWW
« Reply #48 on: June 04, 2009, 02:46:46 AM »

Hey there Swami, could you private message me your two documents? the password protected one, and the actual password-protect one and I'll look at your code for you, If you do not feel safe doing this, it is fine, I would just find it easier to diagnose your problem if I could see the complete code Smiley

-Dan!
Logged

gokhul
Newbie
*
Posts: 1


« Reply #49 on: June 16, 2009, 01:17:24 PM »

Hi,

I dont have a php script in my code.
It is just a data entry page designed using html.
But the file was saved with the '.php' extension.
For such kind of files, can you tell me where to place the code?
Logged
recoding
Global Moderator
Jr. Member
*****
Posts: 71


WWW
« Reply #50 on: June 17, 2009, 05:12:56 AM »

Hi,

I dont have a php script in my code.
It is just a data entry page designed using html.
But the file was saved with the '.php' extension.
For such kind of files, can you tell me where to place the code?
Hey there gokhul, I'm sorry but this will only work in PHP.
Logged

gtswhitt
Newbie
*
Posts: 2


« Reply #51 on: July 01, 2009, 08:43:56 PM »

I can import just about anyone's website files with FrontPage.  Someone can do the same to me.  Can they also import the password_protect.php page that shows all of the passwords?  If so, is there any way to hide a file from downloading from the server to somebody else's computer?
Logged
gtswhitt
Newbie
*
Posts: 2


« Reply #52 on: July 01, 2009, 08:46:03 PM »

Is there a way to add a logout button at the page that has been protected and when the user presses it it sends them back to the login page... I know when the session times out this happens but I want the user to be able to do it aswell...

how would this be done?

Include this code wherever you want the logout button to appear:
Code:
<form method="get" action="(enter your php document here).php?logout" /><input type="submit" value="Logout" /></form>


When I did this, anyone can figure out exactly where your password_protect.php file is located and go straight to it to download from your server with FrontPage, etc. can't they?HuhHuh
Logged
Leonel
Newbie
*
Posts: 1


« Reply #53 on: July 23, 2009, 10:47:55 AM »

I followed the instructions and it works great on all file but one.  On this particular file, edit.php,  the first line of code reads:

<?
$var = @$_REQUEST['cmd'] ;
//connect to mysql


after I place the new line of code in, that I copied from the output of http:// ....com /protector/password_protect.php?  which returns
<?php include("/var/www/html/protector/password_protect.php"); ?>

I do get the login/password window when I try to access the edit file, after I enter the login the entire file comes up.  In that file, which is a membership directory, each name entry is individually editable. When I select to edit a particular entry, I once again get prompted for login/password, I enter the login again and then I get the following error message:

Error updating you: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

SQL: UPDATE directory SET name='',bio='',company='',biotitle='',email='',site='',title='',address='',city='',state='',zip='',phone='',vlink='',vname='',fax='' WHERE id=


If I remove the added code <?php include("/var/www/html/protector/password_protect.php"); ?> , everything works fine.  I tried a varied of different settings including adding php to <? tag or removing php from the added code ... but regardless of whatever I try, I can not get edit.php to function correctly unless I remove the added code.

Any suggestions?
Logged
kerstey
Newbie
*
Posts: 2


« Reply #54 on: August 12, 2009, 04:58:10 AM »

Does this only work on Linux?

I have windows hosting and can't get it to work.  Cry

When I get to this point:

"After you updated settings, save password_protect.php somewhere on your hosting server.
Lets say your website address is http://www.haveahobby.com, and you saved password_protect.php in /htdocs/protector/ folder

Open your browser, and type your site URL + path to the password_protect.php?help
In our example it would be: http://www.haveahobby.com/protector/password_protect.php?help"

It just re-opens the password_protect.php code in explorer

help!!!

Logged
recoding
Global Moderator
Jr. Member
*****
Posts: 71


WWW
« Reply #55 on: August 12, 2009, 05:39:28 AM »

Hmm depends what you mean by windows hosting. One form is a WAMP server (Windows, Apache, MySQL & PHP). Another form is with MSSQL, it uses a really bad scripting language called ASP. or ASP.Net. To find out if your server supports PHP, make a blank .php file (eg php.php) and in it write this:
Code:
<?php phpinfo(); ?>
If it comes out with lots of information, then PHP works, and the above script should work fine. Make sure you followed the instructions correctly Smiley

-Dan
Logged

Pages: 1 2 3 [4] 5
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC