WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
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 Resources
Web Development Content
Internet Security Software
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
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

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 : 2 of 5 (graded 6 times)
Viewed : 32715
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  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>



Db_lib - practical example usage of database abstraction and form validation.
Categories : PHP, Form Processing, PHP Classes, Data Validation, Beginner Guides
PHP and javascript mouseover, mouseout, and mousedown events
Categories : PHP, Java Script, Form Processing, Beginner Guides
Form Validation Using PHP to highlight non valid fields
Categories : PHP, Form Processing, Data Validation, Beginner Guides
Simple Session example
Categories : PHP, Beginner Guides, Sessions
Form Security - Match A Value For Success
Categories : PHP, Authentication, HTML and PHP, Sessions, Security
A beginner's session handling class
Categories : PHP, PHP Classes, Sessions, Beginner Guides
Authenticator for Exchange Server LDAP
Categories : PHP, Authentication, LDAP, Security, Sessions
Simple PHP Form Auto Generation based on MySQL query
Categories : PHP, Form Processing, Databases, MySQL, Sessions
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
session out Timer
Categories : PHP, Sessions, Security, Beginner Guides
Newbie Notes #10 - Generating drop downs
Categories : PHP, MySQL, HTML, Beginner Guides, Databases
Temperature Conversion
Categories : PHP, Math., Beginner Guides
Simple PHP cookie counter
Categories : PHP, Cookies, Beginner Guides
Import the yahoo address book.
Categories : PHP, CURL, Authentication