本要领适合于喜好DIY 博客或DIY模板的博主,先在模板中竖立一个文件(ps:最好是先复制原模板中的pege.php文件,变动一下文件名就能够了, 以zhuce.php为例)
第一步:在新建的zhuce.php中找到<?php echo $log_content; ?>把它替换成以下代码
<?php echo $log_content; ?><table align="center"><form action="" method="post" name="reg" id="reg" onsubmit="return checkReg();"><tr><td align="right">用户名:</td><td><input name="username" class="usr" >* 必填,大于即是5位</td></tr><tr><td align="right">暗码:</td><td><input name="password" type="password">* 必填,大于即是5位</td></tr><tr><td align="right">反复暗码:</td><td><input name="password2" type="password"></td></tr><tr><td align="right">验证码:</td><td><input name="imgcode" type="text" class="imgcode"><img src="<?php echo BLOG_URL; ?>include/lib/checkcode.php" width="80" id="yzcode" /></td></tr><tr><td align="right"></td><td><input type="submit" value="确认注册" class="rbtn"> <input type="reset" value="重置" class="rbtn"></td></tr><tr><td><a href="admin/" title="前去登录">已有账号,前去上岸?</a></td></tr></form></table><?phpsession_start();!defined('EMLOG_ROOT') && exit('access deined!'); if(ROLE == 'admin' || ROLE == 'writer'){header('Location:'.BLOG_URL.'admin/');}global $CACHE;$options_cache = $CACHE->readCache('options');$DB = MySql::getInstance();$username = isset($_POST['username']) ? addslashes(trim($_POST['username'])) : '';$password = isset($_POST['password']) ? addslashes(trim($_POST['password'])) : '';$password2 = isset($_POST['password2']) ? addslashes(trim($_POST['password2'])) : '';$imgcode = isset($_POST['imgcode']) ? strtoupper(addslashes(trim($_POST['imgcode']))): '';if($username && $password && $password2 && $imgcode ){$sessionCode = isset($_SESSION['code']) ? $_SESSION['code'] : '';//echo $sessionCode;if($imgcode == $sessionCode){$User_Model = new User_Model();if(!$User_Model -> isUserExist($username)){$hsPWD = new PasswordHash(8, true);$password = $hsPWD->HashPassword($password);$User_Model->addUser($username, $password, 'writer', 'y');$CACHE->updateCache();echo'<script>alert("注册胜利!"); window.location.href="'.BLOG_URL.'admin/"</script>';}else{echo'<script>alert("用户名已存在!");</script>';}}else{echo'<script>alert("验证码毛病!");</script>';}}?><script type="text/javascript">function checkReg(){var usrName = $("input[name=username]").val().replace(/(^\s*)|(\s*$)/g, "");var pwd = $("input[name=password]").val().replace(/(^\s*)|(\s*$)/g, "");var pwd2 = $("input[name=password2]").val().replace(/(^\s*)|(\s*$)/g, "");var yzm = $("input[name=imgcode]").val().replace(/(^\s*)|(\s*$)/g, "");if(usrName.match(/\s/) || pwd.match(/\s/)){alert("用户名和暗码中不能有空格");return false;}if(usrName == '' || pwd == '' || yzm == ''){alert("用户名、暗码、验证码都不能为空!");return false;}if(usrName.length < 5 || pwd.length < 5){alert("用户名和暗码都不能小于5位!");return false;}else if(pwd != pwd2){alert("两次输入暗码不相等!");return false;}}$(function(){$("#imginfo").click(function(){//alert('haha');$("img#yzcode").attr("src", "<?php echo BLOG_URL;?>include/lib/checkcode.php?"+Math.random());});})</script>第二步:新建一个页面
背景-->>页面-->>新建页面-->>填写页面称号(如:用户注册)-->> 修正页面模板为zhuce-->>宣布-->>完成。

评论列表