<?php
include("../conn.php");
include("../common.php");



$type = "WHERE id='1'";
session_start();
if (ubo($_POST[btn])) {
    $name = ubo($_POST[name]);
    $pass = ubo($_POST[pass]);
    $type = "WHERE user='$name'";
    $row = queryall(zhucema, $type);

    if ($name == null) {
        $err = '<p class="error">账号不能为空</p>';
    } elseif ($pass == null) {
        $err = '<p class="error">密码不能为空</p>';
    } elseif ($row[pass] == $pass and $row[user] == $name) {


        setcookie("username", $name, time() + 7200);
        $_SESSION['username'] = $name;

        if ($row[zdsl] == "1") {
            echo "<script>location.href='daili/home.php'</script>";
        }
        if ($row[zdsl] == "0") {
            echo "<script>location.href='erji/home.php'</script>";
        }
        if ($row[zdsl] == "") {
            echo "<script>location.href='home.php'</script>";
        }

    } else {
        $err = '<p class="error">SORRY！账号或密码错误</p>';
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=gb2312"/>
    <title>魔域代理系统</title>
    <meta name="keywords" content="独家开发"/>
    <link rel="stylesheet" type="text/css" href="newui/login/login.css" media="all"/>
    <link rel="shortcut icon" href="favicon.ico"/>
</head>
<body>
<div class="loginbox">
    <form action="" method="post">
        <div class="huan"><p class="go">魔域代理登陆</p></div>
        <input type="text" name="name" autocomplete="off" class="username text" value="<?php echo $name ?>"
               placeholder="账号" autofocus/>
        <br>
        <input type="text" name="pass" autocomplete="off" class="text password" value="<?php echo $pass ?>"
               placeholder="密码"/>
        <?php echo $err ?>
        <input type="submit" value="代理登陆" name="btn" class="btn"/>
</div>
</body>
</html>