添加字段的坦克验证 [英] Tank Auth Adding Fields

查看:118
本文介绍了添加字段的坦克验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用Tank Auth库,有一个问题。我在注册表单中添加了两个字段:first_name和last_name,我想知道为什么它没有插入到user_profiles页面。



发生此错误:



严重性: 警告



消息:缺少Tank_auth :: create_user()的参数5,在/home/xtremer/public_html/kowmanager/application/controllers/auth.php在第136行调用并定义



文件名:libraries / Tank_auth.php



行号:162
PHP错误遇到



严重性:通知



讯息:未定义属性:Tank_auth :: $ users



文件名:libraries / Tank_auth.php



行号:188



致命错误:在第188行的/home/xtremer/public_html/kowmanager/application/libraries/Tank_auth.php中的非对象上调用成员函数UpdateProfileInfo()


更新代码:



Auth控制器



Tank Auth Library

用户模型



对我现在做错了什么想法?



我会给这50分钱,但我不能得到链接

解决方案

你应该做的是把你想要的两个列放在 user_profiles 表中,然后向 models / tank_auth / users.php 中添加一个函数:

 函数UpdateProfileInfo($ userID,$ firstname,$ lastname)
{
return $ this-> db-& user_profiles',array('firstname'=> $ firstname,'lastname'=> $ lastname),array('user_id'=> $ userID));
}

然后替换 /libraries/Tank_auth.php

function create_user($ username,$ email,$ password,$ email_activation)

使用

函数create_user($ username,$ email,$ password,$ email_activation,$ userInfo)


$ b b

然后在 /libraries/Tank_auth.php 下面

if(!is_null($ res = $ this-> ci-> users-> create_user($ data,!$ email_activation))){
添加

$ this-> users-> UpdateProfileInfo($ userInfo [firstname],$ userInfo [lastname]);



然后替换(在 /controllers/auth.php

  if $ this-> form_validation-> run()){// validation ok 
if(!is_null($ data = $ this-> tank_auth-> create_user(
$ use_username?$ this - > form_validation-> set_value('username'):'',
$ this-> form_validation-> set_value('email'),
$ this-> form_validation-> set_value('password'),
$ email_activation)){// success

  $ userInfo [firstname] = $ this-> form_validation-> set_value(firstname); 
$ userInfo [lastname] = $ this-> form_validation-> set_value(lastname);

if($ this-> form_validation-> run()){// validation ok
if(!is_null($ data = $ this-> tank_auth-> create_user (
$ use_username?$ this-> form_validation-> set_value('username'):'',
$ this-> form_validation-> set_value('email'),
$ this-> form_validation-> set_value('password'),
$ email_activation,$ userInfo))){// success

这没有测试,虽然它应该工作,告诉我怎么走

最大


I've been working with the Tank Auth library all day and have a question about it. I added two fields to the registration form: first_name and last_name respectively and I'm trying to find out why its not inserting into the user_profiles page.

With the updated code I'm getting this error:

A PHP Error was encountered

Severity: Warning

Message: Missing argument 5 for Tank_auth::create_user(), called in /home/xtremer/public_html/kowmanager/application/controllers/auth.php on line 136 and defined

Filename: libraries/Tank_auth.php

Line Number: 162 A PHP Error was encountered

Severity: Notice

Message: Undefined property: Tank_auth::$users

Filename: libraries/Tank_auth.php

Line Number: 188

Fatal error: Call to a member function UpdateProfileInfo() on a non-object in /home/xtremer/public_html/kowmanager/application/libraries/Tank_auth.php on line 188

Updated Code:

Auth Controller

Tank Auth Library

Users Model

Any ideas on what I am doing wrong now?

I'll put a 50 point bounty on this but I can't get the link to come up so that there is a bounty.

解决方案

What You should do is put the two columns you want in the user_profiles table, then add a function to the models/tank_auth/users.php with something like:

function UpdateProfileInfo ($userID, $firstname, $lastname)
{
    return $this->db->update('user_profiles', array('firstname'=>$firstname, 'lastname'=>$lastname), array('user_id' => $userID)); 
}

Then replace (in /libraries/Tank_auth.php)
function create_user($username, $email, $password, $email_activation)
With
function create_user($username, $email, $password, $email_activation, $userInfo)

Then right beneath (in /libraries/Tank_auth.php)
if (!is_null($res = $this->ci->users->create_user($data, !$email_activation))) { Add
$this->users->UpdateProfileInfo($userInfo["firstname"],$userInfo["lastname"]);

Then replace (in /controllers/auth.php)

        if ($this->form_validation->run()) {                                // validation ok
            if (!is_null($data = $this->tank_auth->create_user(
                    $use_username ? $this->form_validation->set_value('username') : '',
                    $this->form_validation->set_value('email'),
                    $this->form_validation->set_value('password'),
                    $email_activation))) {                                  // success

with:

$userInfo["firstname"] = $this->form_validation->set_value("firstname");
$userInfo["lastname"]  = $this->form_validation->set_value("lastname");

if ($this->form_validation->run()) {                                // validation ok
    if (!is_null($data = $this->tank_auth->create_user(
            $use_username ? $this->form_validation->set_value('username') : '',
            $this->form_validation->set_value('email'),
            $this->form_validation->set_value('password'),
            $email_activation, $userInfo))) {                                   // success

This isn't tested though it should work, tell me how it goes
Max

这篇关于添加字段的坦克验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆