![]() |
|
[PHP] Password Protected Webpage. - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Web Development (https://hackforums.net/forumdisplay.php?fid=183) +---- Thread: [PHP] Password Protected Webpage. (/showthread.php?tid=2962412) Pages: Pages
1
2
|
Password Protected Webpage. - Police 10-13 - Oct 22, 2012 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 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 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. :) * - Muhammad Ali - Oct 22, 2012 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 ?>. * - Police 10-13 - Oct 22, 2012 (Oct 22, 2012 03:46 AM)espadian Wrote: Wait, i don't get it really. I may have worded it wrong, but if you type in the correct password, the html code underneath the code will be displayed. * - ManDoR - Oct 22, 2012 Actually, doing a simple htaccess will do the work :p Anyway, I believe it's nice for new php programmers. * - Police 10-13 - Oct 22, 2012 (Oct 22, 2012 04:34 AM)ManDoR Wrote: Actually, doing a simple htaccess will do the work :p I've never done it that way ;) Off Topic: why does it say; WARNING: Potential SPAM or INFECTED LINK image ? 🤮 * - Kabyle - Oct 22, 2012 (Oct 22, 2012 04:34 AM)ManDoR Wrote: Actually, doing a simple htaccess will do the work :p New PHP programmers? So .htaccess isn't for begginers ? Are you kidding? Anyway, off topic, .htaccess is using Apache not PHP. * - Mr Liam - Oct 22, 2012 A possible XSS vuln right here.. Just saying. * - japon - Oct 22, 2012 Saving hardcoded passwords into files.. Hackforums quality at its height, I see. * - Linux. - Oct 22, 2012 Why not do MySQL login? Then if they are logged in as Admin give them certain rights? * - Аrthur - Oct 22, 2012 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. * - ManDoR - Oct 22, 2012 (Oct 22, 2012 04:43 AM)Kabyle Wrote: New PHP programmers? So .htaccess isn't for begginers ? Are you kidding? When you are learning php, htaccess is obviously not the first thing you will learn. * - alphabot - Oct 22, 2012 (Oct 22, 2012 07:20 AM)Liam Allan Wrote: A possible XSS vuln right here.. I really don't see how this has any XSS vulnerabilities as he never outputs anything that the user put in. * - Eight - Oct 22, 2012 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 * - Das Swag - Oct 23, 2012 (Oct 22, 2012 07:20 AM)Liam Allan Wrote: A possible XSS vuln right here.. Can easily fix it by filtering out html special characters * - alphabot - Oct 23, 2012 (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... |