社交网络 PHP/MySQL 结构

发布于 2024-10-12 19:52:02 字数 215 浏览 5 评论 0原文

我想创建一个社交媒体网站。我现在只是在计划,我想首先通过用户名/密码组合登录用户,检查 mysql 数据库并查看它们是否存在。这很简单。但我要问的是,就像 Facebook 一样,对于“Bio”页面,您会添加“从 user_id = $user_id 的朋友中选择”之类的内容吗?那么我是否在整个页面上使用相同的 user_id 来选择评论、联系信息、朋友、图片、喜欢、不喜欢?这是正确的还是这种糟糕的应用程序结构?

I want to create a social media site. I'm just planning it out at the moment, i'm thinking first to log the user in by username/password combo, checking against a mysql db and seeing if they exist. Thats simple enough. But i'm asking is, like Facebook, for a "Bio" page, would you put stuff like "select from friends where user_id = $user_id", that sort of thing? So do i use the same user_id over the whole page for selecting comments, contact info, friends, pictures, likes, dislikes? Is this right or is this poor application structure?

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

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

发布评论

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

评论(2

一抹微笑 2024-10-19 19:52:02

我想你还有很长的路要走。

请不要误解这一点,但您似乎缺乏手动构建这样一个平台所需的技能。

如果您有能力构建一个社交网站,您就会对身份验证系统有深入的了解,但您似乎缺乏这一点。

我建议您使用专门为社交互动(例如 Facebook)构建的自定义开源框架。

这里有一些可以帮助您入门的

I think you ahve a long way to go.

Please dont take this the wrong way but you seem to lack the required skills to manually build such a platform.

If you had it in you to build a social network site you would understand authentications systems down to a tee, but you seem to lack that.

What i would suggest is that you use a custom open source framework specifically built for social interactions such as facebook.

Here a few to get you started

那支青花 2024-10-19 19:52:02

当您登录它们时,从数据库中获取他们的用户 ID(我假设您在用户表中拥有完整的用户 ID 以及用户名/密码)并将其存储在会话中。然后,您可以在站点的所有页面上使用它来进行查询。如果您要将其基于查询字符串或发布数据,人们可以轻松更改它。

这是一种非常标准的做事方式(根据我的经验)。

您还可以将整个用户对象存储在会话变量中,但是您必须担心如何使其保持最新。

When you log them in, get their userID from the database (I'm assuming you have an integral user id as well as their username/password in the user table) and store it in the session. You can then use that on all the pages in your site to do queries. If you were to base it on the query string or post data, people can easily change that.

This is a pretty standard way of doing things (in my experience).

You could also store a whole user object in a session variable, but then you'd have to worry about keeping it up-to-date.

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