如何让PHP页面动态化?
我最近创建了一个网站,用户可以登录并访问各种表单和其他内容。我想知道,登录后,如何更改 php 代码,以便它自动修改页面的一部分,使其个性化?这是前端的屏幕截图。
我希望登录表单部分消失,然后用新的布局替换它。我会使用 Javascript 还是 AJAX?如果有的话,有人对如何开展这个项目有任何指导吗?
I recently created a website where a user logs in and accesses various forms and other things. I was wondering, after login, how can I change the php code so that it automatically modifies a portion of the page making it personal? Here is a screen shot of the front end.
I would like the login form portion disappear and then have a new layout replace it. Would I use Javascript or AJAX. If either, does anyone have any guidance on how to go about doing this project?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来您的目标之一是尽量减少页面刷新,甚至可能根本不刷新。
您的主要挑战包括:
1. 管理可能存在的大量不相关的 DIV,它们构成了您的功能部分。
2. 速度问题——大量代码塞进一页。
3. 所有输入都是异步发送的(当您想用 AJAX 做所有事情时,事情会变得非常复杂!)
至于您的初始登录菜单,您可以通过将其包装在 DIV 中并在其上调用 jQuery 的 fadeOut() 函数来淡出它。要在不刷新的情况下更新 PHP 组件,这就是 AJAX 的用武之地。您将需要使用其中的一些组件,就像 realsix 所说的那样,它们本质上都是以 Javascipt 为核心。
我最好的建议是在规划阶段花费大量时间专门用于该项目。了解如何处理 DIV 相互冲突的情况。开发整体表格布局,使您可以灵活地选择内容 DIV 的进出位置。考虑哪些在任何给定时间是可以更换的。研究模块化编码。
这是广泛的建议,因为我不知道该项目到底需要什么,所以如果您有任何具体问题,请告诉我。
It sounds like one of your goals is to minimize page refreshes, possibly having none at all.
Your main challenges include:
1. Managing possibly lots of unrelated DIVs, which make up your functional segments.
2. Speed issues - lots of code crammed into one page.
3. All input sent asynchronously (things get complicated very fast when you want to do EVERYTHING with AJAX!)
As far as your initial login menu, you can fade that out by wrapping it in a DIV and calling jQuery's fadeOut() function on it. To update PHP components without refresh, that's where your AJAX comes in. You're going to want to use a little of each and like therealsix said, they're all essentially Javascipt at the core.
My best advice would be to spend a big chunk of your time dedicated to this project in the planning stage. Understand how you are going to deal with DIVs crashing into each other. Develop an overall table layout that gives you flexibility concerning where content DIVs come in and out. Think about which ones are replaceable at any given time. Study up on modular coding.
That's broad advice because I don't know what exactly the project entails, so if you have any specific issues, let me know.
我不会说。如果您要更改整个页面,只需重定向到新页面即可。
如果您需要在不重新加载页面的情况下执行此操作,则需要使用 javascript 和 AJAX(ajax 在某种意义上是 javascript)。然后我建议你看看 jquery 函数(http://api.jquery.com/load/)
I would say neither. If you're going to change the whole page, just redirect to a new page.
If you needed to do this without a page reload you would need to use javascript and AJAX (ajax in some sense is javascript). Then I would recommend you look at the jquery functions (http://api.jquery.com/load/)