侧边栏壁纸

Typecho前台登录

2024年09月05日 181阅读 0评论 3点赞

前言
前台登录是个很方便的功能,无论是作为个人博客还是多人博客,前台登录都会节省用户时间。

代码

<form action="<?php $this->options->loginAction()?>" method="post" name="login" rold="form">
<input type="hidden" name="referer" value="<?php $this->options->siteUrl(); ?>">
<input type="text" name="name" autocomplete="username" placeholder="请输入用户名" required/>
<input type="password" name="password" autocomplete="current-password" placeholder="请输入密码" required/>
<button type="submit">登录</button>
</form>

其中 referer 这个input就指明了登录成功后的跳转位置,现在默认的首页,可以修改value的值来自行定义登录成功跳转得地址。

Typecho前台注册

代码

<form action="<?php $this->options->registerAction();?>" method="post" name="register" role="form">
<input type="hidden" name="_" value="<?php echo $this->security->getToken($this->request->getRequestUrl());?>">
用户名<input type="text" name="name">
邮箱:<input type="email" id="mail" name="mail" >
<button type="submit" name="loginsubmit" value="true">注册</button>
</form>

说明
用户进入注册页面,只会要求用户填写用户名和邮箱,点击注册按钮后会跳转到程序后台,此时会提示被分配了个临时密码,同时提示用户修改默认密码,填写个人信息如昵称,个人主页等。

扩展
如果也想像前台登录一样,登陆后自定义跳转页面,需要修改/var/Widget/Register.php这个文件,倒数第三行左右的这个代码this−>response−>redirect(

if (NULL != $this->request->referer) {
$this->response->redirect($this->request->referer);
} else{
$this->response->redirect($this->options->adminUrl);
}

这样在form里插入

<input type="hidden" name="referer" value="跳转地址">

即可。

3个认可

—— 评论区 ——

昵称
邮箱
网址
取消
人生倒计时
最新评论
  • 222691913788
    222691913788
    5天前
  • 222691913788
    222691913788
    5天前
  • 97427613
    97427613
    7天前
  • 墨白
    墨白
    7天前