Php 在我的数据库中,我的申请表数据未存储
我开发了一个表单。它无法正常工作。这是我的代码—所有数据库、模型、控制器类 这是数据库代码 数据库:Php 在我的数据库中,我的申请表数据未存储,php,cakephp,Php,Cakephp,我开发了一个表单。它无法正常工作。这是我的代码—所有数据库、模型、控制器类 这是数据库代码 数据库: CREATE TABLE users ( id INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , username VARCHAR( 40 ) NOT NULL , password VARCHAR( 40 ) NOT NULL , email VARCHAR( 255 ) NOT NULL , first_n
CREATE TABLE users (
id INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
username VARCHAR( 40 ) NOT NULL ,
password VARCHAR( 40 ) NOT NULL ,
email VARCHAR( 255 ) NOT NULL ,
first_name VARCHAR( 40 ) NOT NULL ,
last_name VARCHAR( 40 ) NOT NULL
)
<?php
class User extends AppModel{
var $name='User';
}
?>
<html>
<form action="../users/register" method="post">
<p>Please fill out the form below to register an account.</p>
<label>Username:</label><input name="username" size="40" />
<label>Password:</label><input type="password" name="password" size="40"/>
<label>Email Address:</label><input name="email" size="40" maxlength="255" />
<label>First Name:</label><input name="first_name" size="40" />
<label>Last Name:</label><input name="last_name" size="40" />
<input type="submit" value="register" />
</form>
</html>
<?php
class UsersController extends AppController{
function register(){
if (!empty($this->params['form'])){
if($this->User->save($this->params['form'])){
$this->flash('Registration Successful','/users/register');
} else{
$this->flash('Not succeeded','/users/register');
}
}
}
}
?>
<?php
echo $this->Form->create('User', array(
'controller' => 'users', 'action'=>'register'
));
echo $this->Form->input('username', array(
'size'=>40,
'type' => 'text',
'placeholder'=>__('Your username'),
));
echo $this->Form->input('password', array(
'size'=>40,
'type' => 'password',
'placeholder'=>__('password'),
));
echo $this->Form->input('email', array(
'size'=>40,
'type' => 'email',
'placeholder'=>__('your@email.com'),
));
echo $this->Form->input('first_name', array(
'size'=>40,
'type' => 'text',
'placeholder'=>__('First name'),
));
echo $this->Form->input('last_name', array(
'size'=>40,
'type' => 'text',
'placeholder'=>__('Last name'),
));
echo $this->Form->end('Submit');
?>
public function register(){
if($this->request->is('post')){
if($this->User->save($this->request->data)) {
$this->Session->setFlash(__('Registered'));
$this->redirect('/');
} else {
$this->Session->setFlash(__('Something went wrong!'));
}
}
}
型号类别:
CREATE TABLE users (
id INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
username VARCHAR( 40 ) NOT NULL ,
password VARCHAR( 40 ) NOT NULL ,
email VARCHAR( 255 ) NOT NULL ,
first_name VARCHAR( 40 ) NOT NULL ,
last_name VARCHAR( 40 ) NOT NULL
)
<?php
class User extends AppModel{
var $name='User';
}
?>
<html>
<form action="../users/register" method="post">
<p>Please fill out the form below to register an account.</p>
<label>Username:</label><input name="username" size="40" />
<label>Password:</label><input type="password" name="password" size="40"/>
<label>Email Address:</label><input name="email" size="40" maxlength="255" />
<label>First Name:</label><input name="first_name" size="40" />
<label>Last Name:</label><input name="last_name" size="40" />
<input type="submit" value="register" />
</form>
</html>
<?php
class UsersController extends AppController{
function register(){
if (!empty($this->params['form'])){
if($this->User->save($this->params['form'])){
$this->flash('Registration Successful','/users/register');
} else{
$this->flash('Not succeeded','/users/register');
}
}
}
}
?>
<?php
echo $this->Form->create('User', array(
'controller' => 'users', 'action'=>'register'
));
echo $this->Form->input('username', array(
'size'=>40,
'type' => 'text',
'placeholder'=>__('Your username'),
));
echo $this->Form->input('password', array(
'size'=>40,
'type' => 'password',
'placeholder'=>__('password'),
));
echo $this->Form->input('email', array(
'size'=>40,
'type' => 'email',
'placeholder'=>__('your@email.com'),
));
echo $this->Form->input('first_name', array(
'size'=>40,
'type' => 'text',
'placeholder'=>__('First name'),
));
echo $this->Form->input('last_name', array(
'size'=>40,
'type' => 'text',
'placeholder'=>__('Last name'),
));
echo $this->Form->end('Submit');
?>
public function register(){
if($this->request->is('post')){
if($this->User->save($this->request->data)) {
$this->Session->setFlash(__('Registered'));
$this->redirect('/');
} else {
$this->Session->setFlash(__('Something went wrong!'));
}
}
}
查看类:
CREATE TABLE users (
id INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
username VARCHAR( 40 ) NOT NULL ,
password VARCHAR( 40 ) NOT NULL ,
email VARCHAR( 255 ) NOT NULL ,
first_name VARCHAR( 40 ) NOT NULL ,
last_name VARCHAR( 40 ) NOT NULL
)
<?php
class User extends AppModel{
var $name='User';
}
?>
<html>
<form action="../users/register" method="post">
<p>Please fill out the form below to register an account.</p>
<label>Username:</label><input name="username" size="40" />
<label>Password:</label><input type="password" name="password" size="40"/>
<label>Email Address:</label><input name="email" size="40" maxlength="255" />
<label>First Name:</label><input name="first_name" size="40" />
<label>Last Name:</label><input name="last_name" size="40" />
<input type="submit" value="register" />
</form>
</html>
<?php
class UsersController extends AppController{
function register(){
if (!empty($this->params['form'])){
if($this->User->save($this->params['form'])){
$this->flash('Registration Successful','/users/register');
} else{
$this->flash('Not succeeded','/users/register');
}
}
}
}
?>
<?php
echo $this->Form->create('User', array(
'controller' => 'users', 'action'=>'register'
));
echo $this->Form->input('username', array(
'size'=>40,
'type' => 'text',
'placeholder'=>__('Your username'),
));
echo $this->Form->input('password', array(
'size'=>40,
'type' => 'password',
'placeholder'=>__('password'),
));
echo $this->Form->input('email', array(
'size'=>40,
'type' => 'email',
'placeholder'=>__('your@email.com'),
));
echo $this->Form->input('first_name', array(
'size'=>40,
'type' => 'text',
'placeholder'=>__('First name'),
));
echo $this->Form->input('last_name', array(
'size'=>40,
'type' => 'text',
'placeholder'=>__('Last name'),
));
echo $this->Form->end('Submit');
?>
public function register(){
if($this->request->is('post')){
if($this->User->save($this->request->data)) {
$this->Session->setFlash(__('Registered'));
$this->redirect('/');
} else {
$this->Session->setFlash(__('Something went wrong!'));
}
}
}
请填写以下表格以注册帐户
用户名:
密码:
电邮地址:
名字:
姓氏:
控制器类:
CREATE TABLE users (
id INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
username VARCHAR( 40 ) NOT NULL ,
password VARCHAR( 40 ) NOT NULL ,
email VARCHAR( 255 ) NOT NULL ,
first_name VARCHAR( 40 ) NOT NULL ,
last_name VARCHAR( 40 ) NOT NULL
)
<?php
class User extends AppModel{
var $name='User';
}
?>
<html>
<form action="../users/register" method="post">
<p>Please fill out the form below to register an account.</p>
<label>Username:</label><input name="username" size="40" />
<label>Password:</label><input type="password" name="password" size="40"/>
<label>Email Address:</label><input name="email" size="40" maxlength="255" />
<label>First Name:</label><input name="first_name" size="40" />
<label>Last Name:</label><input name="last_name" size="40" />
<input type="submit" value="register" />
</form>
</html>
<?php
class UsersController extends AppController{
function register(){
if (!empty($this->params['form'])){
if($this->User->save($this->params['form'])){
$this->flash('Registration Successful','/users/register');
} else{
$this->flash('Not succeeded','/users/register');
}
}
}
}
?>
<?php
echo $this->Form->create('User', array(
'controller' => 'users', 'action'=>'register'
));
echo $this->Form->input('username', array(
'size'=>40,
'type' => 'text',
'placeholder'=>__('Your username'),
));
echo $this->Form->input('password', array(
'size'=>40,
'type' => 'password',
'placeholder'=>__('password'),
));
echo $this->Form->input('email', array(
'size'=>40,
'type' => 'email',
'placeholder'=>__('your@email.com'),
));
echo $this->Form->input('first_name', array(
'size'=>40,
'type' => 'text',
'placeholder'=>__('First name'),
));
echo $this->Form->input('last_name', array(
'size'=>40,
'type' => 'text',
'placeholder'=>__('Last name'),
));
echo $this->Form->end('Submit');
?>
public function register(){
if($this->request->is('post')){
if($this->User->save($this->request->data)) {
$this->Session->setFlash(__('Registered'));
$this->redirect('/');
} else {
$this->Session->setFlash(__('Something went wrong!'));
}
}
}
请解决我的问题请准确执行以下代码 在此处更改路径$this->重定向('/');如果不想重定向,请删除该行 查看:
CREATE TABLE users (
id INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
username VARCHAR( 40 ) NOT NULL ,
password VARCHAR( 40 ) NOT NULL ,
email VARCHAR( 255 ) NOT NULL ,
first_name VARCHAR( 40 ) NOT NULL ,
last_name VARCHAR( 40 ) NOT NULL
)
<?php
class User extends AppModel{
var $name='User';
}
?>
<html>
<form action="../users/register" method="post">
<p>Please fill out the form below to register an account.</p>
<label>Username:</label><input name="username" size="40" />
<label>Password:</label><input type="password" name="password" size="40"/>
<label>Email Address:</label><input name="email" size="40" maxlength="255" />
<label>First Name:</label><input name="first_name" size="40" />
<label>Last Name:</label><input name="last_name" size="40" />
<input type="submit" value="register" />
</form>
</html>
<?php
class UsersController extends AppController{
function register(){
if (!empty($this->params['form'])){
if($this->User->save($this->params['form'])){
$this->flash('Registration Successful','/users/register');
} else{
$this->flash('Not succeeded','/users/register');
}
}
}
}
?>
<?php
echo $this->Form->create('User', array(
'controller' => 'users', 'action'=>'register'
));
echo $this->Form->input('username', array(
'size'=>40,
'type' => 'text',
'placeholder'=>__('Your username'),
));
echo $this->Form->input('password', array(
'size'=>40,
'type' => 'password',
'placeholder'=>__('password'),
));
echo $this->Form->input('email', array(
'size'=>40,
'type' => 'email',
'placeholder'=>__('your@email.com'),
));
echo $this->Form->input('first_name', array(
'size'=>40,
'type' => 'text',
'placeholder'=>__('First name'),
));
echo $this->Form->input('last_name', array(
'size'=>40,
'type' => 'text',
'placeholder'=>__('Last name'),
));
echo $this->Form->end('Submit');
?>
public function register(){
if($this->request->is('post')){
if($this->User->save($this->request->data)) {
$this->Session->setFlash(__('Registered'));
$this->redirect('/');
} else {
$this->Session->setFlash(__('Something went wrong!'));
}
}
}