Total members 11864 |It is currently Thu Dec 09, 2021 4:58 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Password protection for a single page. Visitors are required to enter a password and username into a login form to view the page content.

Code:
<?php
// Define your username and password
$username "someuser";
$password "somepassword";
if (
$_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) {
?>
<h1>Login</h1>

<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <p><label for="txtUsername">Username:</label>
    <br /><input type="text" title="Enter your Username" name="txtUsername" /></p>
    <p><label for="txtpassword">Password:</label>
    <br /><input type="password" title="Enter your password" name="txtPassword" /></p>
    <p><input type="submit" name="Submit" value="Login" /></p>
</form>
<?php

}
else {

?>
<p>This is the protected page. Your private content goes here.</p>

<?php

}

?>




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

Notice: Undefined index: txtUsername in D:\xampp\htdocs\index.php on line 13


Author:
Post new topic Reply to topic  [ 2 posts ] 

  Related Posts  to : php Password protect a page
 Protect page using password in PHP     -  
 How to protect your software     -  
 Image Scroller-scrollbar-LINE_UP,LINE_DOWN-PAGE-UP-PAGE-DOWN     -  
 generate password using php     -  
 how to encrypt password in jsp     -  
 simple password Strength checker     -  
 Input username and password in JAVA     -  
 Password Security Manager Access File Java     -  
 AJAX Login Code getting username and password dynamically .     -  
 Mile200: Removing Username, Password & Login from Header     -  









Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com