如何让PHP页面动态化?

发布于 2024-10-28 04:48:23 字数 237 浏览 2 评论 0原文

我最近创建了一个网站,用户可以登录并访问各种表单和其他内容。我想知道,登录后,如何更改 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?

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月亮坠入山谷 2024-11-04 04:48:23

听起来您的目标之一是尽量减少页面刷新,甚至可能根本不刷新。

您的主要挑战包括:
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.

一念一轮回 2024-11-04 04:48:23

我不会说。如果您要更改整个页面,只需重定向到新页面即可。

如果您需要在不重新加载页面的情况下执行此操作,则需要使用 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/)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文