为用户帐户编写系统

发布于 2024-08-10 08:42:15 字数 163 浏览 5 评论 0原文

我正在从头开始构建自己的博客网站(而不是使用 WordPress 或 Drupal)。我将文章设置并存储在数据库中,网站在数据库上运行查询以显示内容。

如何编写一个系统供用户注册网站、编辑个人详细信息以及对文章发表评论?我以前从未做过这样的事情,而且我对 PHP 和 mySQL 的了解也很新鲜。

I am building my own blogging website from scratch (instead of using WordPress or Drupal). I have the articles set up and stored in databases and the website runs queries on the databases to display the content.

How do I write a system for users to register with the site, edit personal details and post comments on the articles? I have never done something like this before and my knowledge of PHP and mySQL is quite fresh.

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

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

发布评论

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

评论(3

尴尬癌患者 2024-08-17 08:42:15

我建议您阅读“头首先是 PHP 和 MySQL”。它为您提供了开始构建网站的好方法。

I suggest you to read "Head First PHP & MySQL " . it gives you a good way to start building a website .

悲喜皆因你 2024-08-17 08:42:15

没有任何 PHP 细节。

如果你想从头开始,一个基本的方法是为用户创建一个单独的表,并从其他表链接该表,在这些表中你需要一条记录与该用户关联,例如让 posts 表中的 user_id 指向该帖子的作者。
然后您需要某种注册表单,最好带有验证码以防止垃圾邮件机器人。
在将密码放入数据库之前对其进行哈希处理也是一种常见的做法。
您还需要使用会话机制来跟踪登录的用户,我想 PHP 提供了一些会话机制。
Web 应用程序的常见安全威胁也可能是一个考虑因素。

Without any PHP sepcifics.

If you want to do it from scratch a basic approach would be to have a separate table for users and have the table linked from other tables where you need a record to be associated with that user, e.g. have user_id in the posts table to point to the author of the post.
Then you'll need a registration form of some kind, pereferably with captcha to guard against spam bots.
It is also a common practice to hash passwords before putting them into the database.
You will also need to use a session mechanism to keep track of logged in users, I suppose PHP provides some session mechanism.
Commons security threats for web applications may be a consideration as well.

凉栀 2024-08-17 08:42:15

您将需要一个 user 表和一个 articles 表。
用户表必须有一个 md5 哈希密码字段(google PHP md5)、用户名和 ID。
文章表必须有一个标题/名称字段、撰写该文章的用户的 ID 以及一个文本字段(文章本身)。

您还可以添加注释选项,但我认为这对于 php 新手来说可能太多了。

看看mysql_real_escape_string,因为当php新手编写mysql/php应用程序时,通常会导致“Sql-Injections”。这意味着用户可以操纵您的数据库,甚至通过您的应用程序接管整个服务器。

You will need a user table and a articles table.
The user table must have a field for the md5'hashed password (google PHP md5), username and ID.
The Articles table must have a field for the heading/name, the ID of the user that wrote it and a field for the text (article itself).

You can also add a Comment option, but I think that could be too much for a php newb.

Have a look at mysql_real_escape_string, because when php-newbies write mysql/php apps, it often results in "Sql-Injections". That means that a user could manipulate your database or even take over the whole server via your application.

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