Heim > Fragen und Antworten > Hauptteil
这是html部分:
<form name="name" action="http://localhost/yb1/Home/curd/create" method="post">
<input type="text" name="学号" value="1446298514" id='xh'>
<input type="submit" name='tj' value="提交">
</form>
这是 creat:
public function create()
{
$use = D('classone');
$use->create();
$use->add();
//上面这些代码,也可能执行失败,执行成功,就执行下面★,执行失败,就执行◆,请问这个怎么写?
//★$this->success('插入成功', 'lastRow',2);
//◆$this->page();
}
巴扎黑2017-04-10 18:03:08
public function create()
{
$use = D('classone');
if($use->create()){
if($use->add()){
$this->success('插入成功', 'lastRow',2);
}else{
$this->error("插入失败!");
}
}else{
$this->error($use->getError())
}
}
伊谢尔伦2017-04-10 18:03:08
public function create()
{
$use = D('classone');
$use->create();
$res=$use->add();
if($res){
$this->success('插入成功', 'lastRow',2);
}
else {
$this->page();
}
}