谁一开始就是大神?

PHP 第10页

PHP

请教一个YII登录问题[2.0]

Neodolphin阅读(92)

现在有很多第三方登录,一个网站有 自带注册登录,QQ登录,微信登录,微博登录等一大堆
那么我怎么区分用户是怎么登录的呢?如何知道用户是QQ登录还是微信登录,因为要通过不同的模型关联不同的第三方数据

我是这样解决的.
1,建立一张用户绑定表(user_oauth2).user_id q openid wx_openid wb_openid
2,然后用户关联这张表就可以知道他有绑定没有了.
已集成 第三方登录

phpstudy的apache集成环境,开启URL美化不能访问,关闭美化正常访问,还望小伙伴点点[2.0]

NewCherry阅读(84)

开启美化:

URL美化.png

关闭美化url:

URL没美化.png

相关代码:
 'urlManager' => [
    'enablePrettyUrl' => true,
    'showScriptName' => false,
    'rules' => [],
 ],
 apache相关配置:
     已加载LoadModule rewrite_module modules/mod_rewrite.so模块
 vhosts相关配置:
  <Directory "D:\WWW\demo\backend\web">
      Options FollowSymLinks ExecCGI
      AllowOverride All
      Order allow,deny
      Allow from all
      Require all granted
  </Directory>
 

web目录加个文件.htaccess
代码:Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
RewriteRule \.svn\/ /404.html
RewriteRule \.git\/ /404.html

yii框架batchInsert不执行beforeSave[2.0]

richelephant阅读(67)

在项目中使用batchInsert 批量插入数据,beforeSave方法不执行,有什么办法可以解决吗?

batchInsert是不走Save()相关事件的,包括数据验证。 如果想使用batchInsert一次性批量添加数据,只好将数据处理好再入库了.

yii2ajax登录[2.0]

CleverEagle阅读(94)

怎样实现ajax登录,当用户名或密码错误的时候,获取到rules中的错误信息

controller:
model:
view:
大概是这样
直接通过json返回吧
兄弟,你这个是自己不想写了吧,类似于外包?
http://www.yiichina.com/doc/guide/2.0/input-forms
记得采纳我的答案。
$model->errors获取错误信息后,你用json返回错误信息给前端,弹窗不弹窗的前端决定

开发组件,扩展Widget时无法调用widget部件[2.0]

Cindyhappy阅读(88)

文件结构如下:
4BA40968-78E1-488A-AEEF-80FDBC4693A8.png

入口:根目录下的text.php

require_once __DIR__ . '/vendor/autoload.php';
use Hello\SayHello;

echo SayHello::world();

SayHello类如下:


namespace Hello;

use app\TestWidgets\ProgressWidget;

class SayHello
{
    public static function world()
    {
        return  122;
        return  ProgressWidget::widget(['message'=>1232213]);
    }

问题是,world方法直接返回122或任何数字,字符串。都可以在页面渲染出来。
如果改成 return ProgressWidget::widget([‘message’=>1232213]); 就会报500

ProgressWidget.php 如下


/**
 *
 */
namespace app\TestWidgets;

class ProgressWidget extends \yii\base\Widget
{
    public $message;

    public function init()
    {
        parent::init();
        if($this->message === null){
            $this->message = '<div class="color:red;">Hello World</div>';
        }else{
            $this->message = '<div style="color:red;">'.$this->message.'</div>';
        }
    }

    public function run(){

        //        return $this->render('hello');
        return 123;
    }

test.php加上require Yii.php

注册表单多添加一个nickname字段,但是这个nickname不在user表,是在profile表[2.0]

Bravebubble阅读(77)

在注册表单中添加了一个nickname的字段让用户选填 ,

先在signupForm中对这个字段Public
如图:
1.png

然后在user的model中对这个字段public
如图:
2.png

在signupForm中,对nickname字段作了rules规则,string,safe,在写入到user表中一切都是正常的,nickname应该是在Insert以后生效,我在user的model中找到insert方法,打印了一下参数,发现nickname并未传值过来
3.png

那就是在我保存user表的时候那一步的问题了,是么?
这个是signupForm中保存用户的那一步:
4.png

求大神指导,我这个nickname如何能够在insert方法中取到值!

没有分了…请大神将就一下吧….

多模型输入!
属性定义在模型里,rules里加safe或者required等等

登录

找回密码

注册