CHttpException当尝试提交带有captcha的表单时


CHttpException when trying to submit a form with a captcha

我是yii框架的新手,我正在尝试在本地zamp环境中执行php应用程序。应用程序在生产环境中正常工作。

我收到的错误是在填写表格并尝试提交之后。captcha没有验证,我在日志中得到以下错误:

2014/11/10 10:23:17 [error] [exception.CHttpException.404] exception 'CHttpException' with message 'The system cannot find the action « undefined » that is requested.' in D:'Users'....'web'CController.php:483
Stack trace:
#0 D:'Users'...'web'CController.php(270): CController->missingAction('undefined')
#1 D:'Users'...'web'CWebApplication.php(282): CController->run('undefined')
#2 D:'Users'...'web'CWebApplication.php(141): CWebApplication->runController('site/undefined')
#3 D:'Users'...'base'CApplication.php(180): CWebApplication->processRequest()
#4 D:'Users'....'index.php(23): CApplication->run()
#5 {main}
REQUEST_URI=/appname/site/undefined
HTTP_REFERER=http://localhost:92/appname/site/form

如何解决此问题或确定导致问题的操作?

**编辑:问题似乎来自这里:验证码与显示的图像不匹配。.**

/**
 * Gets the verification code.
 * @param boolean $regenerate whether the verification code should be regenerated.
 * @return string the verification code.
 */
public function getVerifyCode($regenerate=false)
{
    if($this->fixedVerifyCode !== null)
        return $this->fixedVerifyCode;
    $session = Yii::app()->session;
    $session->open();
    $name = $this->getSessionKey();
    if($session[$name] === null || $regenerate)
    {
        $session[$name] = $this->generateVerifyCode();
        $session[$name . 'count'] = 1;
    }

    $message = $session[$name];
    echo "<script type='text/javascript'>alert('$message');</script>";

    return $session[$name];
}

问题出在哪里?

Ayrad,错误消息非常模糊,比如说,"…action«undefined»……",通常Yii 404错误指定了它的名称(例如,"…无法解决请求"ABC XYZ…")。

这类错误取决于很多事情,比如,是否启用了引擎重写,你的.htaccess如何。至少,你的"URLManager"在你的Config中看起来如何。

所以,我的答案是根据我之前遇到的问题的经验得出的。他们在我的CSS文件中有一些断开的链接,所以我得到了这样的错误,

[error] [exception.CHttpException.404] exception 'CHttpException' with message 'The system is unable to find the requested action "undefined".' in C:'wamp'yii'framework'web'CController.php:484
Stack trace:
#0 C:'wamp'yii'framework'web'CController.php(271): CController->missingAction('undefined')
#1 C:'wamp'yii'framework'web'CWebApplication.php(283): CController->run('undefined')
#2 C:'wamp'yii'framework'web'CWebApplication.php(142): CWebApplication->runController('site/undefined')
#3 C:'wamp'yii'framework'base'CApplication.php(162): CWebApplication->processRequest()
#4 C:'wamp'www'index.php(27): CApplication->run()
#5 {main}
REQUEST_URI=/site/undefined
HTTP_REFERER=http://localhost/site/index

我检查了我的主布局,发现这个有缺陷的javascript函数导致了这个错误:

$(".shortcuts").each(function(){
        var cacheImage = document.createElement('img');
        cacheImage.src = $(this).attr('rel');
        cache.push(cacheImage);
        });

它被假定为在引导导航栏上预加载快捷方式图像。从而解决了问题。希望这能有所帮助。如果没有,请尝试发布更多详细信息。

错误日志清楚地显示了这是怎么回事,

REQUEST_URI=/appname/site/undefined

这表明你以某种方式生成了一个这样的url,当它试图使用它解决问题时,它失败了(我认为这是你的表单url)

您必须共享才能查看生成此表单的内容,否则我们无法帮助您

如果此代码在生产环境中正常工作。那么这个问题可能是由于数据库或main.php不匹配。我认为,这个错误是由于没有正确获取网站操作。请检查,请求的URL是否正确。