WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Basic WWW-Authentication example
Categories : PHP, Authentication Click here to Update Your Picture
Marcus Xenakis
Date : Nov 19th 1999
Grade : 2 of 5 (graded 5 times)
Viewed : 24004
File : account.cgi
Images : No Images for this code example.
Search : More code by Marcus Xenakis
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?php
/*
==================================================================
=========
PROGRAM NAME : Authenticate.php
WRITTEN BY : Marcus S. Xenakis <marcus@xenakis.net>
VERSION : 1.00
LAST MODIFIED : 11/19/99
==================================================================
=========
COPYRIGHT NOTICE :

Copyright (c) 1999 Marcus S. Xenakis. All Rights Reserved.

This program is free software; you can change or modify it as you see fit.
However, modified versions cannot be sold or distributed.

WARRANTY DISCLAIMER:

THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT
ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
FITNESS FOR A PARTICULAR PURPOSE.
==================================================================
=========
DESCRIPTION :


The example below is not a complete program solution. It is a working example
of how to authenticate with any web page using "The Basic Authenication Relm"
from a php script It can be easily be rewritten in Perl.

It reads the enitre page into a 2K buffer string.
In the example below the web browser may have broken links to the graphics
it's trying to retrieve. This is because I echo the HTML contents to
the browser. A real application would process the $html field and extract
the data desired for procesing before display.

A note of caution, the user and password are not displayed via view source in
the displayed page. However if the script fails and the source is displayed,
passwords may be compromised. Also note that your password is stored in the
script that is stored on the site. Presumably only webmasters have access to
your site, but there have been hacks in the past.

The issue is that you should be aware of the security risks involved.
==================================================================
=========
CONFIGURATION :

Five variables must be configured for this script to
work with your site.

$site = "your_domain.com_here";
$user = "your_user_id_here";
$pass = "your_password_here";
$page = "/"; path to page / for index page
$port = 80; HTTP Note: this also has been tested via port 911, not via SSL
I suspect it will not work via SSL because of the encryption
==================================================================
=========
*/

$site = "your_domain.com_here";
$user = "your_user_id_here";
$pass = "your_password_here";
$page = "/";
$port = 80;

$user_pass = "$user:$pass";
$code = base64_encode($user_pass);

echo "<html><title>Account Info</title><body>\n";
$fp = fsockopen($site,$port,$errno,$errstr);
if (!$fp) {
echo "<h2>Error</h2>\n";
echo "$errstr ($errno) <br>\n";
} else {
fputs($fp,"GET $page HTTP/1.0\r\n");
fputs($fp,"Authorization: Basic $code\n\n");
while (!feof($fp)) {
$html = fgets($fp,2048);
echo $html;
}
fclose($fp);
}
echo "</body>\n</html>";
?>



Using $PHP_AUTH_USER and $PHP_AUTH_PW to authenticate.
Categories : Authentication, PHP
basic user validation
Categories : PHP, Authentication
Import the yahoo address book.
Categories : PHP, CURL, Authentication
PHP Function to Encrypt/Decrypt a string without a known key. The string itself has his own different key for every character.
Categories : PHP, Algorithms, Security, Authentication, Encryption
Complete, simple working example of login screen and check on a unique page using php functions, cookies and mysql database.
Categories : PHP, Cookies, MySQL, HTML and PHP, Authentication
Function to remember password
Categories : PHP, Authentication, Personalization and Membership
PHP4 MYSQL Authentication Script with cookie. Short & Sweet
Categories : Authentication, Apache, Cookies, PHP, MySQL
Is there some possibility to link a database to an htaccess file, so that instead of having a passwd file you would have a database with DES-crypted password and username fields?
Categories : Authentication, PHP, General SQL, Databases
Authorize Me! An authentication script.
Categories : MySQL, Databases, Authentication, PHP
Authentication script to authenticate users in Active Directory through LDAP.
Categories : LDAP, Authentication, Cookies, PHP
MD5 secured login
Categories : PHP, Java Script, Authentication, Security
Simple and fast user authentication
Categories : PHP, PHP Classes, Authentication
Full membership authentication system.
Categories : Authentication, MySQL, PHP, Databases
Authentication HTTP protocol POST
Categories : Authentication, HTTP, PHP
Form Security - Match A Value For Success
Categories : PHP, Authentication, HTML and PHP, Sessions, Security