小型bbs论坛系统开发6 前台注册/登录页

来源:互联网 发布:mac不能导入照片 编辑:程序博客网 时间:2024/04/29 14:17
<?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';//二:转义特殊字符,防止sql语句出现错误    $_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';//初始化css$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';    //二、特殊字符转义,防止sql语句出现错误.    $_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'; ?>
0 0