当前位置: 代码迷 >> PHP >> 怎么在这个文件中实现保存账号密码并写入到一个文件中
  详细解决方案

怎么在这个文件中实现保存账号密码并写入到一个文件中

热度:169   发布时间:2012-03-20 14:01:11.0
如何在这个文件中实现保存账号密码并写入到一个文件中?
PHP code
<?
require_once("php/report/include/cookie.php");
$domain = trim($_SERVER["SERVER_NAME"]);
if(file_exists("/var/eyou/apache/htdocs/".$domain))
{
    include("$domain");
    exit;
}
?>

<html>
<title>青岛职业技术学院电子邮件系统</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javascript" src="/js/jquery-1.2.6.js"></script>
<style type="text/css">
<!--
.font{
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    color: #4c4c4c;
}
.input {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    color: #4c4c4c;
}
body{
    margin: 0px;
}
.message{
    color:red;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
}
-->
</style>
<script language="javascript">
$(document).ready(function() {
    $("#submit").click(function(){
        login();
        return false;
    })
});
function login() {
    var messageDefault = "系统错误,请稍候再试。";
    formData = $("input, select").serialize();
    $.ajax({
        type: "post",
        url: "/cgi-bin/user_login",
        data: formData + "&rnd=" + parseInt(Math.random()*9999),
        dataType: "html",
        success: function (dataRes) {
            switch ($.trim(dataRes)) {
                case "0":
                window.location = "/cgi-bin/user_login";
                break;
                case "2":
                $TxtFileName    = "Demo.txt"; 
                //showMessage($TxtFileName);
                showMessage("您输入的用户或密码错误");
                break;
                case "3":
                showMessage("本系统已禁止使用别名登录,请使用真实用户名登录。");
                break;
                case "4":
                showMessage("由于该用户尝试的登录次数达到最大值,已被禁止登录。");
                break;
                case "5":
                    showMessage("您输入的密码错误");
                break;
                case "6":
                    showMessage("该用户已经被锁定");
                break;
                case "7":
                    showMessage("该用户所在的域已经过期");
                break;
                case "8":
                    showMessage("该用户已经过期");
                break;
                case "9":
                    showMessage("您输入的域名错误");
                break;
                case "10":
                    showMessage("用户提交的验证码错误");
                break;
                case "11":
                    showMessage("license过期,请与管理员联系");
                break;
                case "12":
                    showMessage("用户输入的密码过短");
                break;
                case "13":
                    showMessage("导用户信件出错");
                break;
                case "14":
                    showMessage("异常错误");
                break;
                case "15":
                    showMessage("非法用户名");
                break;
                case "16":
                    showMessage("非法域名");
                break;
                case "17":
                    showMessage("您所在的组不允许您用页面登陆邮箱");
                break;
                    default:
                case "1":
                    showMessage(messageDefault);
                break;
            }
        },
        error: function () {
            showMessage(messageDefault);
        }
    });
}

function showMessage(message) {
    $("#message").html(message);
}
</script>
</head>

<body>
<form name=login  method=post id="login">
<table width="995" height="549" align="center" cellpadding="0" cellspacing="0" >
  <tr>
    <td width="285" rowspan="3"><img src="/images/pic_zuo.gif" width="289" height="549"></td>
    <td height="121"><img src="/images/pic_shang.gif" width="418" height="121"></td>
    <td width="288" rowspan="3"><img src="/images/pic_you.gif" width="288" height="549"></td>
  </tr>
  <tr>
    <td height="308" background="/images/pic_zhong.GIF"><table width="60%" align="center" cellpadding="0" cellspacing="7" >
      <tr><br><br>
        <td width="25%" align="right" class="font">用户名:</td>
        <td width="75%"><input name="LoginName" type="text" class="input" size="18"><br/><span id="message" class="message"></span></td>
      </tr>
      <tr>
        <td align="right" class="font">@</td>
        <td>
      <select class=input name=domain style="width:120px">
<?
$lines = @file(get_config('domain_txt'));
if(null == $lines || count($lines)>20)
{
    if(null != $_COOKIE['domainname'] && $_COOKIE['domainname'] != get_config('me'))
    {
        ?>
            <option value="<?= get_config('me') ?>"><?= get_config('me') ?></option>
            <option value="<?= $_COOKIE['domainname'] ?>" selected><?= $_COOKIE['domainname'] ?></option>
        <?
    }
    else
    {
        ?>
            <option value="<?= get_config('me') ?>"><?= get_config('me') ?></option>
        <?
    }
}
else
{
    for($i=0; $i<count($lines); $i++)
    {
        $lines[$i] = ereg_replace("\r","",$lines[$i]);
        $lines[$i] = ereg_replace("\n","",$lines[$i]);
        ?>
            <option value="<?= $lines[$i] ?>" <?= $_COOKIE['domainname']==$lines[$i]?"selected":"" ?>><?= $lines[$i] ?></option>
        <?
    }
}
?>
      </select>
</td>
      </tr>
      <tr>
        <td align="right" class="font">密 码:</td>
        <td><input name="Password" type="password" class="input" size="18"></td>
      </tr>
      <tr>
        <td align="right" class="font">风 格:</td>
        <td><select class=input name="skin" style="width:120px ">
          <option value="">默认</option>
          <option value="blue">蔚蓝天空</option>
          <option value="red">橘子红了</option>
          <option value="silver">银装素裹</option>
          <option value="purple">紫色情怀</option>
          <option value="green">绿意盎然</option>
                        </select></td>
      </tr>
      <tr>
      <!--
        <td align="right" class="font">语 言:</td>
        <td colspan="2" class="font"><input name="locale" type="radio" value="zh_CN" checked>
        中文
        <input type="radio" name="locale" value="en_US">
        英文  <a href="/getpass">找回密码</a></td>
        <td align="center" class="font" colspan="2" height="25"><a href="/getpass">找回密码</a></td>
        -->
        <td align="center" class="font" colspan="2" height="25"><a href="/php/report/osignup.php">邮箱注册</a>
        <a href="/help/help.html">帮助</a>
        <a href="http://www.qtc.edu.cn">返回主页</a></td>
      </tr>
      <tr>
        <td height="25">&nbsp;</td>
        <td><INPUT id="submit" type=image cache src="/images/menu2.gif" border=0 name=log_in target="_blank"></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="120"><img src="/images/pic_xia.gif" width="418" height="120"></td>
  </tr>
</table></FORM>
</body>
</html>
<?php
?>