Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

PHP 

Password Protected Webpage.

I don't think this tutorial has been posted before, It may have been but I did search and couldn't find it.

This tutorial will show you Beginners how to Password Protect you webpage and only be able to access it with the chosen password.(explained further down)


So first, you must have a website or use xampp server.

Secondly, open up your desired text editor, I suggest using Notepad++ or Adobe Dreamweaver.

I must say, the code WON'T be avaliable for Copy&Paste. You must write the code yourself. (Code is supplied).

So... Lets get started;

Firstly, open up the PHP tags like this

PHP Code

<?php

?>

Second; You need to add the function/variable In between the two quotation marks, insert your password.
WARNING: Potential SPAM or INFECTED LINK image (Click to View)

Ok now we are going to add some html blended in with php, (to make the page look nice)
for that we are going to write this code;

WARNING: Potential SPAM or INFECTED LINK image (Click to View)

Done?... Okay, as you can see the php code in that image ends after the last squiggly bracket( { )

Underneath that closing PHP tag, is where you HTML content goes(What you want to show yourself/others if they have the password). So it would look like this;

WARNING: Potential SPAM or INFECTED LINK image (Click to View)

Okay, so now you need to finish off the PHP using the tags underneath the last part of your code add this to it,

PHP Code

<?php 
}
else
{ 

Now we can continue to to finish off the Password Protected Webpage.
Follow on,

Now we need to create the part of the page that show's an error message if the password is typed incorrectly.

This is all blended in with html & php. please type it correctly, or else your code may not work.

WARNING: Potential SPAM or INFECTED LINK image (Click to View)

Once you have done that, you are now ready to upload to your live server or xampp server, your choice..

Your entire code should look something like this(You can edit, change things if you wish)
WARNING: Potential SPAM or INFECTED LINK image (Click to View)
After you have uploaded, navigate to the website & page name.
It should look something sililar to this;(NOTICE: I Created a css layout for mine.)

Completed Webpage (Click to View)

If you got it working correctly, please post here to clarify.

Thank you for reading this tutorial, & I hope you learned something. :)
[Image: dNjfUPi.png]

Click Image; Help fund Police 10-13.
Wait, i don't get it really.

If the person types in a password that you declared in a variable, it will show the HTML code you provided underneath?

But how can you put a curly { bracket, and right after close the php code while you haven't added anything after the "{"?
Because the first curly bracket you put, won't work after the second php code that starts with <?php ?>.
(Oct 22, 2012 03:46 AM)Muhammad Ali Wrote:  Wait, i don't get it really.

If the person types in a password that you declared in a variable, it will show the HTML code you provided underneath?

But how can you put a curly { bracket, and right after close the php code while you haven't added anything after the "{"?
Because the first curly bracket you put, won't work after the second php code that starts with <?php ?>.

I may have worded it wrong, but if you type in the correct password, the html code underneath the code will be displayed.
[Image: dNjfUPi.png]

Click Image; Help fund Police 10-13.
Actually, doing a simple htaccess will do the work :p

Anyway, I believe it's nice for new php programmers.
The Alliance
(Oct 22, 2012 04:34 AM)ManDoR Wrote:  Actually, doing a simple htaccess will do the work :p

Anyway, I believe it's nice for new php programmers.

I've never done it that way ;)

Off Topic:
why does it say; WARNING: Potential SPAM or INFECTED LINK image ? 🤮
[Image: dNjfUPi.png]

Click Image; Help fund Police 10-13.
(Oct 22, 2012 04:34 AM)ManDoR Wrote:  Actually, doing a simple htaccess will do the work :p

Anyway, I believe it's nice for new php programmers.

New PHP programmers? So .htaccess isn't for begginers ? Are you kidding?

Anyway, off topic, .htaccess is using Apache not PHP.
PHP Code

<?php $_GET['money']; ?>
A possible XSS vuln right here..

Just saying.
Saving hardcoded passwords into files.. Hackforums quality at its height, I see.
Why not do MySQL login? Then if they are logged in as Admin give them certain rights?
This is a nice tutorial and will indeed work, it's nice for beginners.
There is just 1 thing.
If you code something in the password checker and it reloads then it doesn't give you the right password, unless you keep sending it with every request.
So I would recommend using sessions which store the password.
(Oct 22, 2012 04:43 AM)Kabyle Wrote:  New PHP programmers? So .htaccess isn't for begginers ? Are you kidding?

Anyway, off topic, .htaccess is using Apache not PHP.

When you are learning php, htaccess is obviously not the first thing you will learn.
The Alliance
(Oct 22, 2012 07:20 AM)Mr Liam Wrote:  A possible XSS vuln right here..

Just saying.

I really don't see how this has any XSS vulnerabilities as he never outputs anything that the user put in.
quit reading my shit
Is this working ? Looks like you're missing a curly brace at the end, you type the if's but not the else's. Anyway, I would've just used elseif instead. Also, if what you're checking for is the correctness of the password, maybe you should compare it against $password ?
Eg :
PHP Code

<?php
if(isset($_POST['password']) && $_POST['password'] == $password)
{
    
/* Password is submitted and is correct */
}
elseif(isset(
$_POST['password']) && $_POST['password'] != $password)
{
    
/* Password is submitted but isn't correct */
}
else
{
    
/* Password isn't submitted */
} 
(Oct 22, 2012 07:20 AM)Mr Liam Wrote:  A possible XSS vuln right here..

Just saying.

Can easily fix it by filtering out html special characters
(Oct 23, 2012 08:21 AM)Das Swag Wrote:  Can easily fix it by filtering out html special characters

I'm still not seeing how the script has a XSS vulnerability...
quit reading my shit


Possibly Related Threads...
Thread / Author Replies Views Last Post
[PHP] by FiftyTwoMar 14, 2015 05:12 PM 4 159 Mar 14, 2015 05:12 PM
Last Post: Squito
[PHP] by alphabotOct 23, 2012 11:43 AM 1 179 Oct 23, 2012 11:43 AM
Last Post: Dogs Toy
[PHP] by Stay PluralNov 26, 2011 02:06 PM 2 159 Nov 26, 2011 02:06 PM
Last Post: Stay Plural