首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >未验证CI表单

问未验证CI表单
EN

Stack Overflow用户
提问于 2012-02-15 06:14:40
回答 1查看 64关注 0票数 0

我试图找出为什么当我运行这个控制器时,它试图运行表单却不能验证它。有什么想法吗?每次我尝试提交表单时,它都会返回失败的验证错误,表明提交表单时出现问题!请刷新窗口,然后重试!

http://www.kansasoutlawwrestling.com/kowmanager/forgotpassword

代码语言:javascript
复制
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

 class Forgotpassword extends CI_Controller { 

public function __construct()
{
    parent::__construct();
    $this->load->library('kow_auth');  
    $this->load->model('kow_auth/users');           
}   

public function index()
{
    //Config Defaults Start
    $msgBoxMsgs = array();//msgType = dl, info, warn, note, msg
    $cssPageAddons = '';//If you have extra CSS for this view append it here
    $jsPageAddons = '<script src="http://www.kansasoutlawwrestling.com/kowmanager/assets/js/forgotvalidate.js"></script>';//If you have extra JS for this view append it here
    $metaAddons = '';//Sometimes there is a need for additional Meta Data such in the case of Facebook addon's
    $siteTitle = '';//alter only if you need something other than the default for this view.
    //Config Defaults Start


    //examples of how to use the message box system (css not included).
    //$msgBoxMsgs[] = array('msgType' => 'dl', 'theMsg' => 'This is a Blank Message Box...');

    /**********************************************************Your Coding Logic Here, Start*/

    if (!$this->session->userdata('xtr') == "yes") {
        $bodyContent = "forgot_password_form";//which view file
    } else {
        $bodyContent = "dashboard";//which view file
    }

    $bodyType = "full";//type of template

    /***********************************************************Your Coding Logic Here, End*/

    //Double checks if any default variables have been changed, Start.
    //If msgBoxMsgs array has anything in it, if so displays it in view, else does nothing.      
    if(count($msgBoxMsgs) !== 0)
    {
        $msgBoxes = $this->msgboxes->buildMsgBoxesOutput(array('display' => 'show', 'msgs' =>$msgBoxMsgs));
    }
    else
    {
        $msgBoxes = array('display' => 'none');
    }

    if($siteTitle == '')
    {
        $siteTitle = $this->metatags->SiteTitle(); //reads 
    }

    //Double checks if any default variables have been changed, End.

    $this->data['msgBoxes'] = $msgBoxes;
    $this->data['cssPageAddons'] = $cssPageAddons;//if there is any additional CSS to add from above Variable this will send it to the view.
    $this->data['jsPageAddons'] = $jsPageAddons;//if there is any addictional JS to add from the above variable this will send it to the view.
    $this->data['metaAddons'] = $metaAddons;//if there is any addictional meta data to add from the above variable this will send it to the view.
    $this->data['pageMetaTags'] = $this->metatags->MetaTags();//defaults can be changed via models/metatags.php
    $this->data['siteTitle'] = $siteTitle;//defaults can be changed via models/metatags.php
    $this->data['bodyType'] = $bodyType;
    $this->data['bodyContent'] = $bodyContent;
    $this->load->view('usermanagement/index', $this->data);
}

function forgot_password_submit()
{
    $this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean');

    if (!$this->form_validation->run()) 
    {
        echo json_encode(array('error' => 'yes', 'message' => 'There was a problem submitting the form! Please refresh the window and try again!'));    
    }
    else
    {
        if (!is_null($user_data = $this->kow_auth->forgot_password($this->input->post('username')))) 
        {
            // Send email with password activation link
            $this->kow_auth->send_email('forgot_password', 'KOW Manager Forgot Password Email', $user_data);
        }   
    }          
}

}

/* End of file forgotpassword.php */ 
/* Location: ./application/controllers/forgotpassword.php */ 
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-02-15 06:28:07

看起来您包含了一个不适用于此表单的jQuery验证脚本。您链接到的页面的第66行如下:

代码语言:javascript
复制
<script src="http://www.kansasoutlawwrestling.com/kowmanager/assets/js/forgotvalidate.js"></script>

将表单数据发布到以下URL:

代码语言:javascript
复制
http://www.kansasoutlawwrestling.com/kowmanager/register/register_submit

反过来,该页面会向您显示错误消息:

代码语言:javascript
复制
{"error":"yes","message":"There was a problem submitting the form! Please refresh the window and try again!"}

我假设你想让“忘记密码”页面发布到它自己(http://www.kansasoutlawwrestling.com/kowmanager/forgotpassword)。

您需要删除jQuery验证脚本,或者对其进行修改,使其与“忘记密码”页面一起工作。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9285005

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档