dtoq41429 2018-05-29 02:19
浏览 72

为什么我无法在AngularJS,php和MySQL的项目上建立会话?

I am working on a login system using AngularJS,php, andMySQL. I am following this tutorial on creating an AngularJS user signup and login authentication using php & MySQL. When I put it on "live", I get the error message below:

Failed to load resource: the server responded with a status of 404 (Not Found) angularlogin/files/functions/session:1 Failed to load resource:

I have checked my phpinfo for session, which is is enabled. What is wrong?

  • 写回答

1条回答 默认 最新

  • douhaodang0403 2018-05-29 02:46
    关注

    Not the definite answer (comments are too limited), but I spun up the project you linked to, I get almost the same error:

    angular.min.js:77 GET .../files/functions/session 500 (Internal Server Error)

    But a 500, not 404 so you probably need to give us more info. 404 (file not found) could mean you have forgotten to copy some files?

    Anyway:

    1. You can always check the server logs, I got ErrorException: mysqli::__construct(): (HY000/1049): Unknown database 'angularjs_login'. If this is your problem, you've just forgotten to create the database on the server.

    2. During development, don't use the production angularjs (angular.min.js), instead use the non-minified version (angular.js) because you'll get much better error messages!

    3. Open the network tab in your browser dev-tools (press F12), click the failed request (sessions) marked in red when not selected, and if your php-settings allows it, you can see the the error straight away under the preview-tab. enter image description here


    If you are sure you have copied all files, here is a qualified guess:

    Your webserver is not configured for slim. Which requires all requests to go through the main index.php, in your case files/functions/index.php. If there is a request to say files/functions/session (which does not exist), the webserver will redirect that request to index.php which sorts the request and passes it along to the right place.

    If the request does not go through index.php, then you'll get a 404-error.

    Slim solves does this by using a .htaccess-file. files/functions/.htaccess. On windows it might be a hidden file, which could be a reason you've missed it.

    Or, your webserver is configurated to not care about .htaccess-files, then you have to change your webserver settings.

    Or, you have a webserver that doesn't use .htaccess-files at all, (like nginx) then you have to find another way to redirect those requests. I suggest you have a look at https://www.slimframework.com/docs/v3/start/web-servers.html

    There is too little info for us to know for sure, but I think the above seems somewhat likely anyway.

    评论

报告相同问题?

悬赏问题

  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?