Location: PHPKode > projects > Openology PHP Application Integration > openology/install/login_data.php
<?php
/***************************************************************************
 *   copyright            : (C) 2006 The openology Group
 *   email                : hide@address.com
 *
 *   $Id
 *
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

    require_once(dirname(__FILE__)."/config_base.php");
    session_start();
if (isset($_POST['ad_name']) && isset($_POST['ad_pass']))
{
  //用户尝试登陆
  $ad_name = $_POST['ad_name'];
  $ad_pass = $_POST['ad_pass'];
  

  $db_conn = mysql_connect("$dbhost", "$dbusername", "$dbuserpwd");
  mysql_select_db("$dbname");
  mysql_query("SET NAMES 'utf8'");
  $query="select * from bbb_user where ad_name='$ad_name' and ad_pass='".md5(trim($ad_pass))."'";
  $result=mysql_query($query);
  $num=mysql_num_rows($result);
  if ($num > 0)
  {
     //如果数据库里有用户注册的信息
     $_SESSION['valid_user'] = $ad_name;
  }
    mysql_close($db_conn);
  }
  ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Login</title>
    <link href="css/login.css" rel="stylesheet" type="text/css" title="Default" />
<script src="js/md5.js"></script>
<script src="js/login_focus.js"></script>
<script type="text/javascript">
function login_form_validation(formobject)
{
    var value = '';
    var errFlag = new Array();
    errMsg = '';
    
    
    if (formobject.elements['ad_user'].value == '')
    {
        errMsg = errMsg + 'Please input username!\n';
    }
    
    if (formobject.elements['ad_pass'].value == '')
    {
        errMsg = errMsg + 'Please input password!\n';
    }
    if (formobject.elements['ad_pass'].value != "")
    formobject.elements['md5password'].value = MD5(formobject.elements['ad_pass'].value);

    if (errMsg != '')
    {
        alert(errMsg);
        return false;
    }
    return true;
}
</script>

</head>
<body>
<?php
  if (isset($_SESSION['valid_user']))
  {
    ShowMsg("$ad_name,$welcome","index.php");
  }
  else
  {
    if (isset($ad_name))
	{
	//如果用户登陆失败
	ShowMsg("$userError","login.php");
    }
echo ' <div id="loginbox">';
echo ' <div id="logo">';
echo ' <img alt="" src="img/logo.png" height="40" width="220" title="openology.org" />    </div>';
echo ' <div id="loginbody">';

echo ' <form  name="login_form"  action="login.php"  method="post"  id="login_form"  onsubmit="return login_form_validation(this);">';
echo ' <table border="0">';
echo ' <tr> ';
echo '  <td colspan="2" id="loginheader">Login to Backend</td>';

echo ' </tr>';
echo ' <tr> ';
echo '  <td colspan="2" id="loginerror"></td>';
echo ' </tr>';
echo ' <tr id="logincontent"> ';
echo '  <td width="5%" align="right"><label for="username">User name</label>:</td>';
echo '  <td width="15%"><input type="text" id="ad_name" name="ad_name" tabindex="1" title="Enter your User name"   /></td>';
echo '  </tr>';
echo ' <tr id="logincontent"> ';
echo '  <td width="5%" align="right"><label for="password">Password</label>:</td>';

echo '  <td width="15%"><input type="password" id="ad_pass" name="ad_pass" tabindex="2" title="Enter your Password"   /></td>';
echo ' </tr>';
echo ' <tr> ';
echo '  <td colspan="2" id="logininfotext"></td>';
echo ' </tr>';
echo '  <tr> ';
echo '  <td colspan="2"> ';
echo '  <div align="right"><input type="submit" id="log in" name="log in" class="submit" value="&nbsp; OK &nbsp; " tabindex="3" title="Click to Login"   />&nbsp;<input type="reset" id="resetbutton" name="resetbutton" class="button" value="Cancel" title="Click to clear info"   /></div>';
echo '  </td>';
echo ' </tr>';

echo ' <tr> ';
echo '  <td colspan="2"> ';
echo '   <div align="right"><a href="">Forgot Password</a></div>';
echo '  </td>';
echo '  </tr>';
echo ' </table>';
echo ' <input type="hidden" id="op" name="op" value="checklogin"   />';
echo ' <input type="hidden" id="md5password" name="md5password"   />';
echo '  </form>';

echo ' </div>';
echo '</div>';

echo '<div id="footer"> <span class="nobr">&copy;2006 openology.org</span></div>    ';
  }
?>
</body>
</html>
Return current item: Openology PHP Application Integration