duanpang5583 2012-10-25 02:27
浏览 123

使用PHP身份验证脚本的Javascript登录页面 - 哪种实现最好?

I wrote a working php authentication script for my HTTP file Server. Now, I want to write a login page with some nice graphics. I usually write my pages in HTML5, javacscript, and CSS. I am not sure how to implement the php authentication script. So far I have two ways I think I know of:

  1. Write the login page in html5 and javascript, use ajax call to the php script after user enters name/password in input boxes, pass the username and password to the script, and have php return ether true or false depending on if that user was authenticated. Problem is, I do not know how to get php return true or false to javascript.

  2. Write a PHP front controller model where the index.php loads html5, javascript, and css for graphics and if user is authenticated then redirect to the normal index.html document for the html file server. The problem with this is I am not familiar with using php as the front controller and I don't know if I can dynamically change elements with javascript for special effects just as if it was a normal html5 page.

  • 写回答

3条回答

  • douma5954 2012-10-25 02:31
    关注

    I would suggest the first solution. You can use http://api.jquery.com/jQuery.post/ to get your php return to javascript.

    评论

报告相同问题?

悬赏问题

  • ¥60 Python如何后台操作Vmwake虚拟机键鼠
  • ¥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,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容