CakePHP 和 PHP更改用户的个人资料
我已经开始学习cakePHP,现在面临以下问题。如何允许我的用户更改他们的个人资料(他们在数据库中的信息)。
这是我的模型 -> http://bin.cakephp.org/view/798927304 当有人尝试时,我会使用这些验证登记 。 这是我编辑配置文件的方法: http://bin.cakephp.org/view/841227800
首先,我检查用户是否有权编辑此配置文件(该配置文件是他自己的)。 然后获取所需的id并尝试保存请求->数据...但不幸的是没有成功。
最后这是我的观点 -> http://bin.cakephp.org/view/1798312426
我唯一想做的是: -更改他们的电子邮件(如果他们添加新电子邮件) -更改他们的社交资料(如果添加他们) -更改他们的密码(如果他们添加了密码)
你能指导我做这些事情吗?
提前致谢!
I have started learning cakePHP and now I am facing the following problem. How can allow my users to change their profile (their info in the DB).
This is my model -> http://bin.cakephp.org/view/798927304 I use these validations when someone tries to register .
This is my method for editing profiles: http://bin.cakephp.org/view/841227800
First I check does the user have the permission to edit this profile (is the profile his own).
Then get the desired id and try to save the request->data... But unfortunately without success.
And last this is my view -> http://bin.cakephp.org/view/1798312426
The only things I want to make are:
-Change their email (if they add new email)
-Change their social profiles (if the add them)
-Change their password (if they add it)
Can you guide me to do these things?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通常,当您调用保存时,如下所示:
$this->request->data 中的数据默认被清除。在您的编辑方法中,下面有一个 if 语句,它再次使用相同的保存。
我假设您从 cakebaked 编辑方法复制的默认功能通常会进行保存并使用返回的逻辑来支持 if 语句。第二次调用它时,您可能会返回 false,这可能会跳过该 if 语句。
为了调试这个,我建议在不同的位置中使用其中的几个:
此外,调试打印输出在重定向时被清除,因此同时,您可能需要注释掉 if 语句内的重定向,如下所示:
Typically, when you call a save, as in:
The data in $this->request->data is cleared by default. In your edit method, you have an if statement below that is using the same save again.
The default functionality which I assume you have copied from a cakebaked edit method typically does the save and uses the returned logic to power that if statement. The second time you call it, you might be getting a false returned, which is likely skipping over that if statement.
To debug this, I suggest several of these in different locations:
Also, debug printouts are cleared on redirect, so in the mean time, you may want to comment out the redirect inside the if statement like so:
可能会做你想做的事。
更多 @ http://book.cakephp.org/view/1031/Saving-Your -数据
may do what you're after.
more @ http://book.cakephp.org/view/1031/Saving-Your-Data