Location: PHPKode > projects > PHP Navigator > navphp4.39/login.php
<?php
#---------------------------
# PHP Navigator 4.37
# dated: January 23, 2009
# Coded by: Cyril Sebastian,
# Kerala,India
# web: navphp.sourceforge.net
#---------------------------

session_start();
include_once("config.php");
include_once("functions.php");

// verifies the login

if($_SESSION['loggedin']) 
{
header("Location:index.php"); 	// redirect if already logged in
exit;
}

#------Not logged in --------- 
// cleans up the users' input
$user_i = clean_input($_POST['user']);
$passwd_i = clean_input($_POST['passwd']);
$action = clean_input($_POST['action']);

/// user verification
if(!$multi_user&&!$enable_login) $login=true;

else if(!$multi_user&&($user_i==$user)&&($passwd_i==$passwd)&&$enable_login) 
{
	$login=true;
}
else if($multi_user)
{ 
	mysql_connect($mysql_server,$mysql_user,$mysql_passwd) or die("MySQL authentication failure!");
	mysql_query("use $mysql_db");
	$result=mysql_query("select * from $mysql_table where user='$user_i' AND passwd='$passwd_i'");
	  
	if(mysql_num_rows($result)>0)
	   {
	   $login=true;
	   $row=mysql_fetch_array($result,MYSQL_NUM);
	   $homedir=$row[2];
	   $rdonly=$row[3];
	   }
	else $login=false;
	
}

	
if (!$login) {
		session_unset();
		session_destroy();
		$_SESSION['loggedin'] = 0;
		$_SESSION['homedir'] = "";
		$_SESSION['rdonly'] = "";
		if($action) $msg= "Authentication failed!";
} else {
		$_SESSION['loggedin'] = 1;
		$_SESSION['homedir'] = $homedir;
		$_SESSION['rdonly'] = $rdonly;
		header("Location:index.php"); 
		exit;
}
?>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>PHP Navigator- Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<link href="inc/windows.css" rel="stylesheet" type="text/css">
</head>
<script>
function login_focus()
{
document.getElementById("user").focus();
}
</script>
<body onLoad=login_focus();><form  method="post" action="">
<table width="100%"  border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center" valign="middle"><p>&nbsp;</p>
      <p>&nbsp;</p>
      <table width="300"  border="0" align="center" cellpadding="0" cellspacing="0" class="lefthead">
      <tr>
        <td class="head"><center class="title"> <img src=images/logoff.gif align=left><strong>PHP Navigator - Login</strong>
        </center></td>
        </tr>
    </table>    
	<table width="300"  border="0" align="center" cellpadding="6" cellspacing="0" class="window">
      <tr>
        <td align="left" >User</td>
        <td align="left" >
          <input name="user" type="text" value="<?php print $user_i ?>" size="20" id=user></td>
      </tr>
      <tr>
        <td align="left">Password</td>
        <td align="left" ><input name="passwd" type="password" size="20"></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td align="left" ><input name="action" type="submit" id="action" value="Login"> 
          <?php print "<font color=red>$msg</font>"; ?></td>
      </tr>
    </table></td>
  </tr>
</table>
</form>
</body>
</html>
Return current item: PHP Navigator