我自己学习cakephp.我试图创建一个带有changepassword功能的用户控制器.它有效,但我不确定这是否是最好的方法,我无法在这方面搜索有用的教程.这是我的代码:
class UsersController extends AppController {
var $name = 'Users';
function login() {
}
function logout() {
$this->redirect($this->Auth->logout());
}
function changepassword() {
$session=$this->Session->read();
$id=$session['Auth']['User']['id'];
$user=$this->User->find('first',array('conditions' => array('id' => $id)));
$this->set('user',$user);
if (!empty($this->data)) {
if ($this->Auth->password($this->data['User']['password'])==$user['User']['password']) {
if ($this->data['User']['passwordn']==$this->data['User']['password2']) {
// Passwords match, continue processing
$data=$this->data;
$this->data=$user;
$this->data['User']['password']=$this->Auth->password($data['User']['passwordn']);
$this->User->id=$id;
$this->User->save($this->data);
$this->Session->setFlash('Password changed.');
$this->redirect(array('controller'=>'Toners','action' => 'index'));
} else {
$this->Session->setFlash('New passwords differ.');
}
} else {
$this->Session->setFlash('Typed passwords did not match.');
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
password是旧密码,passwordn是新密码,password2是新密码.还有其他更多的coomon方式在蛋糕中做到吗?
我浏览了python socket docs和谷歌两天,但我没有找到任何答案.是的我是一个网络编程新手:)
我想实现一些具有特定功能的局域网聊天系统,以满足我们的需求.我刚开始.我能够实现客户端 - 服务器模型,其中客户端连接到服务器(socket.SOCK_STREAM),他们能够更改消息.我想向前迈进一步.我希望客户端通过广播发现有多少其他客户端可用.我失败了.socket.SOCK_STREAM类型套接字是否可能无法用于此任务?如果是这样,我的机会是什么?使用udp包?我如何监听brodcast消息/数据包?
我有一个来自客户端的任务来更正页面,我发现jQuery后代选择器没有按预期运行.
这是HTML的一个excrept:
<form action="http://submit.url/subscribe.php" method="post" enctype="multipart/form-data" id="mssysform8217" class="mssysform" >
<div id="mssys-formcontainer">
<div class="formfields">
<table style="width: 100%">
<div class="formfield-item" id="formfield-item-email">
<tr>
<td class="style1"><label >E-mail címe</label></td>
<td>
<input type="text" name="email" value="">
<div class="error-container">Please fill in this field!</div>
<div style="clear: both;"></div>
</td>
</tr>
</div>
</table>
</div>
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
我尝试用FireFox调试它:
这工作:
console.debug($("#mssysform8217 :input[name='email']").val());
Run Code Online (Sandbox Code Playgroud)
test@gmail.com
这没效果:
console.debug($("#mssysform8217 #formfield-item-email :input[name='email']").val());
Run Code Online (Sandbox Code Playgroud)
未定义
但:
console.debug($("#mssysform8217 #formfield-item-email"));
Run Code Online (Sandbox Code Playgroud)
[DIV#formfield项-email.formfield项目]
问题是提交脚本是由第三方应用程序生成的,它想要使用3级后代选择器.
我在这个问题上生气,请有人帮助我:)
我有这个型号:
订单hasMany - > Orderitem hasOne - > Product
产品有字段vendor_id.
我想对具有特定vendor_id的产品的订单进行分页.
我怎么能做到这一点?
我在orders_controller中的代码:
if(!empty($this->data['Order']['vendor_id'])) {
$conditions['Product.vendor_id']=$this->data['Order']['vendor_id'];
}
if(!empty($this->data['Order']['startdate'])) {
$conditions['Order.date >=']=$this->data['Order']['startdate'];
}
if(!empty($this->data['Order']['enddate'])) {
$conditions['Order.date <=']=$this->data['Order']['enddate'];
}
$this->paginate=array('conditions'=>$conditions,'order'=>'Order.id ASC');
Run Code Online (Sandbox Code Playgroud)
它在'where子句'错误中提供了未知列'Product.vendor_id'.我用Containable尝试了几件但没有成功:(