Go Back   Gaming Gutter > Non-Gaming > Programming > Tutorials


Tutorials - Looking for programming tutorials to increase your knowledge? Do so here.

» Site Navigation
» Home
» FAQ
» Log in
User Name:

Password:

Not a member yet?
Register Now!
» Advertisement
» Recent Threads
Go to first new post How many of you got iced...
Yesterday 09:07 PM
Last post by Renzocooking
Today 12:32 PM
8 Replies, 9 Views
Go to first new post What are image clicks?
Today 12:29 PM
Last post by DarkenedSky
Today 12:31 PM
1 Replies, 2 Views
Go to first new post This account has been...
Today 11:49 AM
Last post by wilsoniscool
Today 12:31 PM
10 Replies, 11 Views
Go to first new post i am leaving neopets so...
Today 10:56 AM
by hamza
Last post by hamza
Today 12:29 PM
6 Replies, 7 Views
Go to first new post Selling Tons of Legit...
07-17-2008 05:47 PM
by Crim
Last post by Crim
Today 12:29 PM
360 Replies, 361 Views
Reply
 
LinkBack Thread Tools Display Modes

 Password protect a page using php
Old 10-18-2006, 03:36 PM   #1 (permalink)
Oosband
Guest
 
Posts: n/a
iTrader: / %
Password protect a page using php

Page Code:
Code:
<html>

<head>
<title>Secured Area</title>
</head>

<body>
<?php

// Define your username and password
$username = "user";
$password = "password";

if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) {

?>



Login
</p>
<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<div align="center">
<center>
<table border="0" cellpadding="5" cellspacing="0">
<tr>
<td><label for="txtUsername">Username</label>
</td>
<td><input type="text" title="Enter your Username" name="txtUsername" /></td>
</tr>
<tr>
<td><label for="txtpassword">Password</label>
</td>
<td><input type="password" title="Enter your password" name="txtPassword" /></td>
</tr>
</table>
</center>
</div>
<p align="center"><input type="submit" name="Submit" value="Login" /></p>
</form>

<?php
}
else {
?>



Place your secret content here.</p>

<?php
}
?> 

</body>

</html>
What we have done is made 2 variables - user and password.
These will be the login details needed to access the protected page.
What then happens is we set the form to open the content if these variables are the same, otherwise access is denied.
  Reply With Quote
Reply

Bookmarks



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
{Basic} Wanna pw protect any of your own coded programs? {VB6} Flame Tutorials 3 11-17-2006 05:22 PM
Random Password Generator Oosband Tutorials 0 10-18-2006 03:42 PM
go to page... stewnb Website Suggestions 3 10-11-2006 05:23 PM
Tips To Protect Your Neopets Account imported_Justin Neopets 1 09-28-2006 04:45 AM

Powered by vBadvanced CMPS v3.0 RC2

All times are GMT -7. The time now is 12:32 PM.


vBulletin skin developed by: eXtremepixels
The contents of this webpage are copyright © 2006-2008 GamingGutter.com. All Rights Reserved.

Page generated in 0.15792298 seconds (100.00% PHP - 0% MySQL) with 20 queries