<?php
include_once './inc/config.inc.php';
include_once './inc/mysql.inc.php';
include_once './inc/tool.inc.php';
$link = sql_connect();
if($id = is_login($link)){
skip('index.php','error','你已经登录了,无需再注册!');
}
if(isset($_POST['submit'])){
include_once './inc/check_register.inc.php';
$_POST = sql_escape($link,$_POST);
$query = "select * from sfk_member where username = '{$_POST['username']}'";
$result = sql_execute($link,$query);
if(mysqli_num_rows($result) == 1){
skip('register.php','error',"用户{$_POST['username']}已经存在");
}
$query = "insert into sfk_member(username,password,register_time)
values('{$_POST['username']}',
md5('{$_POST['password']}'),
now())";
sql_execute($link,$query);
if(mysqli_affected_rows($link) == 1){
setcookie("sfk[username]","{$_POST['username']}");
setcookie("sfk[password]",md5("{$_POST['password']}"));
skip('index.php','ok','用户注册成功!');
}else{
skip('register.php','error','用户注册失败!');
}
}
?>
<?php include_once './inc/header.inc.php';?>
<div id="register" class="auto">
<h2>欢迎注册成为 私房库会员</h2>
<form method = "POST">
<label>用户名:<input type="text" name = 'username'/>
<span>*请合法填入用户名</span>
</label>
<label>密码:<input type="password" name = 'password' />
<span>*请合法填入密码</span>
</label>
<label>确认密码:<input type="password" name = 'password2' />
<span>*请输入上方的密码</span>
</label>
<label>验证码:<input name="vcode" type="text" />
<span>*请输入下方验证码</span>
</label>
<img class="vcode" src="style/show_code.php" onClick="this.src='style/show_code.php?nocache='+Math.random()"/>
<div style="clear:both;"></div>
<input class="btn" type="submit" value="确定注册" name = 'submit' />
</form>
</div>
<?php include_once './inc/footer.inc.php';?>
<?php
include_once './inc/config.inc.php';
include_once './inc/mysql.inc.php';
include_once './inc/tool.inc.php';
$cssArray = array('public.css','register.css');
$webTitle = '用户登录页';
$link = sql_connect();
if(is_login($link)){
skip('index.php','ok',"{$_COOKIE['sfk']['username']},您已经登录,正在返回首页!");
}
if(isset($_POST['submit'])){
include_once './inc/check_login.inc.php';
$_POST = sql_escape($link,$_POST);
$query = "select * from sfk_member
where username = '{$_POST['username']}'
and password = md5('{$_POST['password']}')";
$result = sql_execute($link,$query);
if(mysqli_num_rows($result) == 1){
setcookie("sfk[username]","{$_POST['username']}",time()+$_POST['time']);
setcookie("sfk[password]",md5("{$_POST['password']}"),time()+$_POST['time']);
if(isset($_GET['url'])){
skip($_GET['url'],'ok',"{$_POST['username']},欢迎回来");
}else{
skip('index.php','ok',"{$_POST['username']},欢迎回来");
}
}else{
skip('login.php','error','您的账户信息有误!');
}
}
?>
<?php include_once './inc/header.inc.php';?>
<div id="register" class="auto">
<h2>欢迎登录</h2>
<form method = 'POST'>
<label>用户名:<input type="text" name = 'username'/><span></span></label>
<label>密码:<input type="password" name = 'password' /><span></span></label>
<label>验证码:<input name="vcode" type="text" /><span>*请输入下方验证码</span></label>
<img class="vcode" src="style/show_code.php" onClick="this.src='style/show_code.php?nocache='+Math.random()"/>
<label>自动登录:
<select style="width:236px;height:25px;" name="time">
<option value="3600">1小时内</option>
<option value="86400">1天内</option>
<option value="259200">3天内</option>
<option value="2592000">30天内</option>
</select>
<span>*公共电脑上请勿长期自动登录</span>
</label>
<div style="clear:both;"></div>
<input class="btn" type="submit" name = 'submit' value="登录" />
</form>
</div>
<?php include_once './inc/footer.inc.php'; ?>