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.

    评论

报告相同问题?

悬赏问题

  • ¥50 易语言把MYSQL数据库中的数据添加至组合框
  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况