douzhaiyuan1731 2013-05-07 02:22
浏览 34

在HTML5开发中使用Javascript to PHP?

So I am designing a HTML5 site and I have some data in textfields for example, "password" that I need to store into the database on the Apache server. So far I have designed a simple HTML5 site which is capable of passing data to a PHP script for the handling of server information.

If I plan to use Javascripts to implement login/registers, etc is it possible for the Javascript to parse data to my PHP script and will there be any security flaws involved by doing this? Is it also advisable/recommended to have my HTML5 page parse data directly to the PHP page for the handling of storage or are there better methods/means out there?

  • 写回答

1条回答 默认 最新

  • dongyuli0964 2013-05-07 02:32
    关注

    Using Javascript to pass the data back to the server is fine, but comes with a few caveats.

    First off, you might want to consider a fallback for browsers that don't have js available.

    Secondly, and much more importantly: Never trust the client. It's difficult to guarantee that data you receive on the server will have gone through all the checks in the browser. The simplest way to deal with it is to make any validation / cleaning that you do on the frontend in javascript also be done on the backend with PHP before you let anything hit your database.

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?