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 Authentication with sessions
Categories : PHP, Beginner Guides, Authentication, Form Processing, Sessions Click here to Update Your Picture
Dicho Banov
Date : Jan 18th 2006
Grade : 3 of 5 (graded 5 times)
Viewed : 13871
File : 4293.php
Images : No Images for this code example.
Search : More code by Dicho Banov
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

Auth.php
========
<?php
$root
="c:/inetpub/wwwroot/MySite/"; //full path of folder(user)
session_start();
$_SESSION['username'] = $username;
$_SESSION['password']   = $password;
//if (isset($logout))
//{
if ($logout==true)
{
unset(
$HTTP_SESSION_VARS['username']);
unset(
$HTTP_SESSION_VARS['password']);
echo
"<meta http-equiv=refresh content=\"0;URL=$SCRIPT_NAME\">";
}
//}
if (file_exists($root."user/".$username.".txt"))
{
//1
$fp=fopen($root."user/".$username.".txt","r");
$contents=fread($fp,filesize($root."user/".$username.".txt"));
fclose($fp);
$info=explode("|",$contents);
$username1=trim($info[0]);
$password1=trim($info[1]);
if(
$password1 == trim($HTTP_SESSION_VARS['password']))
{
//2
?>
<!//your script starts here when account is valid--->
<! Insert your code here ---->
Password Protected Website<br>
YOU ARE LOGIN AS <? echo $username ?>  <br>

<a href=<?php echo"$SCRIPT_NAME";?>?logout=1>Logout</a>


<!//your script ends here--->
<?php
}//2
else
{
//2
$err="Invalid Password";
include(
"login.html");
unset(
$HTTP_SESSION_VARS['username']);
unset(
$HTTP_SESSION_VARS['password']);
session_destroy();
}
//2
}//1
else
{
$err="Invalid Username";
include(
"login.html");
unset(
$HTTP_SESSION_VARS['username']);
unset(
$HTTP_SESSION_VARS['password']);
session_destroy();
}
?>


login.html
==========
<html>
<head><title>login</title></head>
<body bgcolor=gold>
<center>
<form method=post action=<? echo "$SCRIPT_NAME"; ?>>
<table border=1 cellpadding=3 celspacing=3 align=center width=50%>
<tr><td colspan=2 align=center>Login</td></tr>
<tr><td colspan=2 align=center><?php if (isset($username)){if ($logout==false){if(isset($err)){echo "$err";}}}?></td></tr>
<tr><td>Username:</td><td><input type=text name=username size="20"></td><tr>
<tr><td>Password:</td><td><input type=password name=password size="20"></td><tr>
<tr><td colspan=2><input type=submit></td><tr>
</table>
</form>
</body>
</html>



A beginner's session handling class
Categories : PHP, PHP Classes, Sessions, Beginner Guides
Db_lib - practical example usage of database abstraction and form validation.
Categories : PHP, Form Processing, PHP Classes, Data Validation, Beginner Guides
Simple PHP Form Field Generator
Categories : PHP, Beginner Guides, Form Processing, HTML and PHP
A simple PHP login script that you can modify to suite your needs. It use a session to store data in a session file submited by the page.
Categories : PHP, Sessions, Security, Authentication
Form Validation Using PHP to highlight non valid fields
Categories : PHP, Form Processing, Data Validation, Beginner Guides
Form Security - Match A Value For Success
Categories : PHP, Authentication, HTML and PHP, Sessions, Security
PHP and javascript mouseover, mouseout, and mousedown events
Categories : PHP, Java Script, Form Processing, Beginner Guides
Simple Session example
Categories : PHP, Beginner Guides, Sessions
Authenticator for Exchange Server LDAP
Categories : PHP, Authentication, LDAP, Security, Sessions
session out Timer
Categories : PHP, Sessions, Security, Beginner Guides
Using $PHP_AUTH_USER and $PHP_AUTH_PW to authenticate.
Categories : Authentication, PHP
Function to remember password
Categories : PHP, Authentication, Personalization and Membership
PHP4 MYSQL Authentication Script with cookie. Short & Sweet
Categories : Authentication, Apache, Cookies, PHP, MySQL
Introduction to Language Files
Categories : PHP, Filesystem, Beginner Guides
email new items in db
Categories : PHP, Email, Databases, MySQL, Beginner Guides