我想使用cakephp将表单数据插入数据库。我在layouts文件夹中创建了form.ctp文件。现在我如何在$(function() {
$('#tblAppendGrid').appendGrid({
// Object containing the definitions of the table rows
initRows: RowDefinitons,
// Your LOV Data
initData: LOVData
});
});
文件中将表单值插入数据库?
这是我的代码:
form.ctp
答案 0 :(得分:0)
<html>
<form action="../users/register" method="post">
<p>Please fill out the form below to register an account.</p>
<label>Username:</label><input name="users[username]" size="40" />
<label>Password:</label><input type="users[password]" name="password" size="40" />
<label>Email Address:</label><input name="users[email]" size="40"
maxlength="255" />
<label>First Name:</label><input name="users[first_name]" size="40" />
<label>Last Name:</label><input name="users[last_name]" size="40" />
<input type="submit" value="register" />
</form>
</html>
并按
保存if ($this->request->is('post')) {
$this->User->save($this->request->data);
}
OR
,无需更改表单即可保存数据if ($this->request->is('post')) {
$this->request->data['User'] = $this->request->data;
$this->User->save($this->request->data);
}