|
|
|
|
|
|
| |
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 | |
|
|
|