图形验证密码POST提交失败
来源:10-5 通用商用网站手机验证码模块实现
切切在心
2017-11-06
网络:状态:错误提示是500 Internal Server Error,这个问题在前面的章节也有遇到过。
开始我以为可能和笔记本的32位系统有关,换到台式上也还是提示这个错误。然后phpStudy集成环境各个版本和wamp也试过了,实在对这个没招了。
希望老师能给我一些方向提示。
Apache提示:127.0.0.1 - - [06/Nov/2017:17:00:06 +0800] "POST /default/get_captcha HTTP/1.1" 500 946
<?php
namespace app\controllers;
use app\common\components\BaseWebController;
use app\common\services\captcha\ValidateCode;
use app\common\services\ConstantMapService;
use app\common\services\UtilService;
use app\models\sms\SmsCaptcha;
class DefaultController extends BaseWebController
{
public function actionIndex(){
//$this->layout = false;
return $this->render("index");
}
private $captcha_cookie_name = "validate_code";
//生成GD图形校验码
public function actionImg_captcha(){
$font_path = \Yii::$app->getBasePath() ."/web/fonts/captcha.ttf";
$captcha_handle = new ValidateCode($font_path);
$captcha_handle->doimg();
$this->setCookie($this->captcha_cookie_name,$captcha_handle->getCode());
}
//获取验证码
public function actionGet_captcha(){
$mobile = $this->post("mobile","");
$img_captcha = $this->post("img_captcha","");
//验证手机号
if(!$mobile || !preg_match('/^1[0-9]{10}$',$mobile)){
$this->removeCookie($this->captcha_cookie_name);
return $this->renderJson([],"请输入正确的手机号码",-1);
}
//图形校验码
$captcha_code = $this->getCookie($this->captcha_cookie_name);
if(strtolower($img_captcha) != $captcha_code){
$this->removeCookie($this->captcha_cookie_name);
return $this->renderJson([],"请输入正确的图形校验码\r\n图形校验码错{$img_captcha},正确的是{$captcha_code}",-1);
}
//发送手机验证码
$model_sms = new SmsCaptcha();
$model_sms->geneCustomCaptcha($mobile,UtilService::getIP());
$this->removeCookie($this->captcha_cookie_name);
if($model_sms){
return $this->renderJson([],"发送成功".$model_sms->captcha);
}
return $this->renderJson([],ConstantMapService::$default_syserror,-1);
}
}感觉和代码没太大关系,代码都是完全对照视频写的。最让我疑惑的是,后台登录的时候也是POST方法为什么就可以,这里和图片上传就会出现这个问题?
好像这个才是Apache的报错
[Mon Nov 06 15:44:47.650819 2017] [mpm_winnt:notice] [pid 5452:tid 464] AH00455: Apache/2.4.9 (Win32) PHP/5.5.12 configured -- resuming normal operations [Mon Nov 06 15:44:47.650819 2017] [mpm_winnt:notice] [pid 5452:tid 464] AH00456: Apache Lounge VC11 Server built: Mar 16 2014 12:13:13 [Mon Nov 06 15:44:47.650819 2017] [core:notice] [pid 5452:tid 464] AH00094: Command line: 'E:\\wamp\\bin\\apache\\apache2.4.9\\bin\\httpd.exe -d E:/wamp/bin/apache/apache2.4.9' [Mon Nov 06 15:44:47.700819 2017] [mpm_winnt:notice] [pid 5452:tid 464] AH00418: Parent: Created child process 7292 [Mon Nov 06 15:44:50.917824 2017] [mpm_winnt:notice] [pid 7292:tid 380] AH00354: Child: Starting 64 worker threads. [Mon Nov 06 16:04:00.652946 2017] [mpm_winnt:notice] [pid 5452:tid 464] AH00422: Parent: Received shutdown signal -- Shutting down the server. [Mon Nov 06 16:04:02.662390 2017] [mpm_winnt:notice] [pid 7292:tid 380] AH00364: Child: All worker threads have exited. [Mon Nov 06 16:04:02.693392 2017] [mpm_winnt:notice] [pid 5452:tid 464] AH00430: Parent: Child process 7292 exited successfully. [Mon Nov 06 16:08:12.198173 2017] [mpm_winnt:notice] [pid 6600:tid 464] AH00455: Apache/2.4.9 (Win32) PHP/5.5.12 configured -- resuming normal operations [Mon Nov 06 16:08:12.198173 2017] [mpm_winnt:notice] [pid 6600:tid 464] AH00456: Apache Lounge VC11 Server built: Mar 16 2014 12:13:13 [Mon Nov 06 16:08:12.198173 2017] [core:notice] [pid 6600:tid 464] AH00094: Command line: 'E:\\wamp\\bin\\apache\\apache2.4.9\\bin\\httpd.exe -d E:/wamp/bin/apache/apache2.4.9' [Mon Nov 06 16:08:12.238173 2017] [mpm_winnt:notice] [pid 6600:tid 464] AH00418: Parent: Created child process 7796 [Mon Nov 06 16:08:13.260175 2017] [mpm_winnt:notice] [pid 7796:tid 380] AH00354: Child: Starting 64 worker threads. [Mon Nov 06 16:09:03.266672 2017] [mpm_winnt:notice] [pid 6600:tid 464] AH00422: Parent: Received shutdown signal -- Shutting down the server. [Mon Nov 06 16:09:05.268675 2017] [mpm_winnt:notice] [pid 7796:tid 380] AH00364: Child: All worker threads have exited. [Mon Nov 06 16:09:05.278675 2017] [mpm_winnt:notice] [pid 6600:tid 464] AH00430: Parent: Child process 7796 exited successfully. [Mon Nov 06 16:09:07.563686 2017] [mpm_winnt:notice] [pid 3312:tid 468] AH00455: Apache/2.4.9 (Win32) PHP/5.5.12 configured -- resuming normal operations [Mon Nov 06 16:09:07.563686 2017] [mpm_winnt:notice] [pid 3312:tid 468] AH00456: Apache Lounge VC11 Server built: Mar 16 2014 12:13:13 [Mon Nov 06 16:09:07.563686 2017] [core:notice] [pid 3312:tid 468] AH00094: Command line: 'E:\\wamp\\bin\\apache\\apache2.4.9\\bin\\httpd.exe -d E:/wamp/bin/apache/apache2.4.9' [Mon Nov 06 16:09:07.603686 2017] [mpm_winnt:notice] [pid 3312:tid 468] AH00418: Parent: Created child process 7384 [Mon Nov 06 16:09:08.759888 2017] [mpm_winnt:notice] [pid 7384:tid 384] AH00354: Child: Starting 64 worker threads. [Mon Nov 06 16:11:31.340669 2017] [mpm_winnt:notice] [pid 3312:tid 468] AH00422: Parent: Received shutdown signal -- Shutting down the server. [Mon Nov 06 16:11:33.343672 2017] [mpm_winnt:notice] [pid 7384:tid 384] AH00364: Child: All worker threads have exited. [Mon Nov 06 16:11:33.353672 2017] [mpm_winnt:notice] [pid 3312:tid 468] AH00430: Parent: Child process 7384 exited successfully. [Mon Nov 06 16:11:34.514673 2017] [mpm_winnt:notice] [pid 6724:tid 468] AH00455: Apache/2.4.9 (Win32) PHP/5.5.12 configured -- resuming normal operations [Mon Nov 06 16:11:34.514673 2017] [mpm_winnt:notice] [pid 6724:tid 468] AH00456: Apache Lounge VC11 Server built: Mar 16 2014 12:13:13 [Mon Nov 06 16:11:34.514673 2017] [core:notice] [pid 6724:tid 468] AH00094: Command line: 'E:\\wamp\\bin\\apache\\apache2.4.9\\bin\\httpd.exe -d E:/wamp/bin/apache/apache2.4.9' [Mon Nov 06 16:11:34.554673 2017] [mpm_winnt:notice] [pid 6724:tid 468] AH00418: Parent: Created child process 3448 [Mon Nov 06 16:11:35.615675 2017] [mpm_winnt:notice] [pid 3448:tid 384] AH00354: Child: Starting 64 worker threads. [Mon Nov 06 16:21:11.519185 2017] [mpm_winnt:notice] [pid 6724:tid 468] AH00422: Parent: Received shutdown signal -- Shutting down the server. [Mon Nov 06 16:21:13.522188 2017] [mpm_winnt:notice] [pid 3448:tid 384] AH00364: Child: All worker threads have exited. [Mon Nov 06 16:21:13.552188 2017] [mpm_winnt:notice] [pid 6724:tid 468] AH00430: Parent: Child process 3448 exited successfully. [Mon Nov 06 16:27:52.331832 2017] [mpm_winnt:notice] [pid 1180:tid 468] AH00455: Apache/2.4.9 (Win32) PHP/5.5.12 configured -- resuming normal operations [Mon Nov 06 16:27:52.347432 2017] [mpm_winnt:notice] [pid 1180:tid 468] AH00456: Apache Lounge VC11 Server built: Mar 16 2014 12:13:13 [Mon Nov 06 16:27:52.347432 2017] [core:notice] [pid 1180:tid 468] AH00094: Command line: 'E:\\wamp\\bin\\apache\\apache2.4.9\\bin\\httpd.exe -d E:/wamp/bin/apache/apache2.4.9' [Mon Nov 06 16:27:52.924633 2017] [mpm_winnt:notice] [pid 1180:tid 468] AH00418: Parent: Created child process 3344 [Mon Nov 06 16:27:54.219436 2017] [mpm_winnt:notice] [pid 3344:tid 384] AH00354: Child: Starting 64 worker threads.
写回答
1回答
-
500属于代码错误,请看看yii2 的 错误日志,还有可以单行调试看看到底哪一行报错的
012017-11-07
相似问题