Wednesday, 07 January 2009
   
Home arrow Tutorial  
 
Home
Supporto
Contattaci
Categorie Script
RSS Media Grabber Video & Foto Divertenti Storie di Vita (Flash) Video: Ricerca & Download Script Download Video Nazioni in Vendita Script per Sondaggi Host per File wap Script Creazione SlideShow Script PhotoCube Script "Make Confessions" Script Spartiti Chitarra Crea Smile Personalizzati URL Brevi & Sottodomini Script Gioco Hot Or Not Metti il Tuo Testo Sulle Img Host & Watermark Img Salva i Tuoi Preferiti Online Componenti Joomla Script a Basso Costo
Partners
StileGames
Php Tutorial
 
 
   
 
.htaccess Password Protection Print E-mail

This tutorial helps you learn how to super protect your files without the use of mySQL.

The code can be split up into three if-else statements. Let's take a look at what we will have to do in order to set up the password protection:

  1. If the user has not been authenticated, then use the PHP header and ask for a username and password.

  2. Else, if the user's name is "spoono" and the password is "spoono", log in. Inside here you would put all the code for the user.

  3. Else tell them the user/password failed.

Finally, here is the PHP Code:

<?
//part 1
if (!isset($PHP_AUTH_USER))
{
header("WWW-Authenticate: Basic realm=\"Spoono Password.\"");
Header("HTTP/1.0 401 Unauthorized");
exit;
}

//part 2
else if(($PHP_AUTH_USER=="spoono") && ($PHP_AUTH_PW=="spoono"))
{
echo "You got in...";
//place the code for the whole user page in here
//you can also set up a redirect to the user page if you want
}

//part 3
else
{
echo "<html><body bgcolor=ffffcc>Faiiiiiiiil";
//fail try again
}
?>

 Some notes about this script: it is essential to note that this username and password will last the whole session, that means that as long as that explorer window is open, the name and password will be saved for that realm. So if you mistyped the name or the password, you'll have to close the explorer window and re-open it and try again.

Credit: www.spoono.com 

 





Reddit!Del.icio.us!Facebook!Slashdot!Netscape!Technorati!StumbleUpon!Newsvine!Furl!Yahoo!Ma.gnolia!Free social bookmarking plugins and extensions for Joomla! websites!
 
< Prev   Next >
 
Se trovi uno dei nostri operatori online, contattalo prima di comprare per usufruire di uno sconto!
Servizi
Controlla PageRank
Richiedi un Preventivo
Script Gratuiti
Installazione Script
Blog Backlinks
Login Form
Prodotti Scontati
RSS Media Grabber
RSS Media Grabber
$129.00
$79.00
You Save: $50.00
Add to Cart
 
Copyrighted © 2006 phppod.com