4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 Authentication to Access Page
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
Justin
4WebHelp Addict
4WebHelp Addict


Joined: 07 Jan 2002
Posts: 1060

PostPosted: Sun Apr 28, 2002 2:46 pm (15 years, 5 months ago) Reply with QuoteBack to Top

Right!

I've just designed my PHP News Script, although the thing is anyone can access it by visiting the appropriate page on my site, and then can publish there articles, what I wanted to do, is get a box to pop up in internet explorer asking for a username and password to access the page (news.php), how would I do this?

Thanks

Justin
OfflineView User's ProfileFind all posts by JustinSend Personal MessageSend email
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Sun Apr 28, 2002 4:05 pm (15 years, 5 months ago) Reply with QuoteBack to Top

Isn't it possible to use .htaccess Password Protection?

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
Darren
Team Member



Joined: 05 Feb 2002
Posts: 549
Location: London

PostPosted: Sun Apr 28, 2002 4:24 pm (15 years, 5 months ago) Reply with QuoteBack to Top

If its just one file could you hard code the username and password into the script.

How secure would this be?
OfflineView User's ProfileFind all posts by DarrenSend Personal MessageVisit Poster's Website
Justin
4WebHelp Addict
4WebHelp Addict


Joined: 07 Jan 2002
Posts: 1060

PostPosted: Sun Apr 28, 2002 4:29 pm (15 years, 5 months ago) Reply with QuoteBack to Top

403 Sad

Code:

HTACCESS :
AuthName "The Kop Online News Administration"
AuthType Basic
AuthUserFile .htpasswd
Allow From All
<Files news.php>
Deny From All
</Files>



http://www.koponline.cc/news.php
OfflineView User's ProfileFind all posts by JustinSend Personal MessageSend email
Justin
4WebHelp Addict
4WebHelp Addict


Joined: 07 Jan 2002
Posts: 1060

PostPosted: Sun Apr 28, 2002 4:31 pm (15 years, 5 months ago) Reply with QuoteBack to Top

Darren wrote:
If its just one file could you hard code the username and password into the script.

How secure would this be?


I'd rather have the pop-up box to be honest, so the visitors can't see the admin page!
OfflineView User's ProfileFind all posts by JustinSend Personal MessageSend email
Darren
Team Member



Joined: 05 Feb 2002
Posts: 549
Location: London

PostPosted: Sun Apr 28, 2002 4:33 pm (15 years, 5 months ago) Reply with QuoteBack to Top

Firstly do you need to provide the full path to the .htpassword file? I did when I set mine up.

Secondly, how did you generate the password? it took me several attempts with various scripts people had online before I found one that worked.
OfflineView User's ProfileFind all posts by DarrenSend Personal MessageVisit Poster's Website
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Sun Apr 28, 2002 4:34 pm (15 years, 5 months ago) Reply with QuoteBack to Top

Try this?

Code:
<Files news.php>
AuthName "The Kop Online News Administration"
AuthType Basic
AuthUserFile .htpasswd
</Files>

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
Justin
4WebHelp Addict
4WebHelp Addict


Joined: 07 Jan 2002
Posts: 1060

PostPosted: Sun Apr 28, 2002 4:39 pm (15 years, 5 months ago) Reply with QuoteBack to Top

Daniel wrote:
Try this?

Code:
<Files news.php>
AuthName "The Kop Online News Administration"
AuthType Basic
AuthUserFile .htpasswd
</Files>

now it doesn't ask for any authentication, goes straight to the script Sad
OfflineView User's ProfileFind all posts by JustinSend Personal MessageSend email
Darren
Team Member



Joined: 05 Feb 2002
Posts: 549
Location: London

PostPosted: Sun Apr 28, 2002 4:40 pm (15 years, 5 months ago) Reply with QuoteBack to Top

What about?

Code:
<?

if($username != "myusername" && $password != "mypassword") {

   // Login form
   //i.e. two text inputs with names 'username' and 'password' and a submit button
   
} else {

   //your news script

}   

?>   
OfflineView User's ProfileFind all posts by DarrenSend Personal MessageVisit Poster's Website
Justin
4WebHelp Addict
4WebHelp Addict


Joined: 07 Jan 2002
Posts: 1060

PostPosted: Sun Apr 28, 2002 4:41 pm (15 years, 5 months ago) Reply with QuoteBack to Top

Darren wrote:
Firstly do you need to provide the full path to the .htpassword file? I did when I set mine up.

Secondly, how did you generate the password? it took me several attempts with various scripts people had online before I found one that worked.

The script is in the root directory, along with the .htaccess and .htpasswd file.

Generated the password using the tool suggested in the tutorial on this site!
OfflineView User's ProfileFind all posts by JustinSend Personal MessageSend email
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Sun Apr 28, 2002 4:41 pm (15 years, 5 months ago) Reply with QuoteBack to Top

Well, try this then:

Code:
if ($password=="yourpassword") {

ALL YOUR CODE HERE

}

else {

print ("Please login.");


Then access your script like this:

news.php?password=yourpassword

You'll then have to include the password in all links in your script, if there are any.

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
Justin
4WebHelp Addict
4WebHelp Addict


Joined: 07 Jan 2002
Posts: 1060

PostPosted: Sun Apr 28, 2002 4:44 pm (15 years, 5 months ago) Reply with QuoteBack to Top

Daniel wrote:
Well, try this then:

Code:
if ($password=="yourpassword") {

ALL YOUR CODE HERE

}

else {

print ("Please login.");


Then access your script like this:

news.php?password=yourpassword

You'll then have to include the password in all links in your script, if there are any.


I may use that as a stopgap, but I really need a solution with a pop-up password box for a few clients that I am designing sites for, as the problem would be, as you can guess, people can see the password just by looking at the address bar if they are watching you.
OfflineView User's ProfileFind all posts by JustinSend Personal MessageSend email
Daniel
Team Member



Joined: 06 Jan 2002
Posts: 2564

PostPosted: Sun Apr 28, 2002 4:46 pm (15 years, 5 months ago) Reply with QuoteBack to Top

Could you password protect the whole directory (and if needed move the script to it's own directory)?

________________________________
Image
OfflineView User's ProfileFind all posts by DanielSend Personal Message
Justin
4WebHelp Addict
4WebHelp Addict


Joined: 07 Jan 2002
Posts: 1060

PostPosted: Sun Apr 28, 2002 4:48 pm (15 years, 5 months ago) Reply with QuoteBack to Top

Daniel wrote:
Could you password protect the whole directory (and if needed move the script to it's own directory)?

Yeah, but the trouble is that http://www.koponline.cc/article_summary.html is included on the front page, with the headlines, I tried it in http://www.koponline.cc/news, but as you can probbably guess, when you include a file, the paths screw up, eg, it points to http://www.kopoline.cc/articlefilename.html, not http://www.koponline.cc/news/articlefilename.html
OfflineView User's ProfileFind all posts by JustinSend Personal MessageSend email
Darren
Team Member



Joined: 05 Feb 2002
Posts: 549
Location: London

PostPosted: Sun Apr 28, 2002 4:52 pm (15 years, 5 months ago) Reply with QuoteBack to Top

Justin wrote:
I may use that as a stopgap, but I really need a solution with a pop-up password box for a few clients that I am designing sites for, as the problem would be, as you can guess, people can see the password just by looking at the address bar if they are watching you.


Then do it my waywith a little form and use session variables to keep them logged in between pages.
OfflineView User's ProfileFind all posts by DarrenSend Personal MessageVisit Poster's Website
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   


Go to page 1, 2  Next

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot edit your posts in this forum.
You cannot delete your posts in this forum.
You cannot vote in polls in this forum.


Page generation time: 0.059378 seconds :: 17 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme