一、注册案例
这个案例和官网上的一样
1、创建数据库,之后创建模型(这个就不多说了)
2、增加一个新的Action
public function registerAction() { $user = new Users(); $success = $user->save($this->request->getPost(), array(‘name‘, ‘email‘)); if($success){ echo " thanks for registering!"; } else { echo " Sorry, the following problems were generated:<br/> "; foreach($user->getMessages() as $message){ echo $message->getMessage(), "<br/>"; } } $this->view->disable(); }
3、模板输出提交
<?php use Phalcon\Tag; ?> <h2>Sign up using this form</h2> //form这里主要的是根据Action写 <?php echo Tag::form("register"); ?> <p> <label for="name">Name</label> <?php echo Tag::textField("name") ?> </p> <p> <label for="email">E-Mail</label> <?php echo Tag::textField("email") ?> </p> <p> <?php echo Tag::submitButton("Register") ?> </p> </form>
二、
时间: 2024-11-13 07:53:34