Advertisement
Guest User

Untitled

a guest
Jun 24th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. public function actionSignup()
  2. {
  3. $model = new User();
  4.  
  5. // collect user input data
  6. if(isset($_POST['User']))
  7. {
  8. $model->attributes=$_POST['User'];
  9.  
  10. // validate user input and redirect to the previous page if valid
  11. $model->setAttributes(array(
  12. 'datereg' => time(), //additional data you want to insert
  13. 'lastlogin' => time() //additional
  14.  
  15. ));
  16.  
  17. if($model->save())
  18. {
  19. //optional
  20. $login=new LoginForm;
  21. $login->username = $_POST['User']['username'];
  22. $login->password = $_POST['User']['password'];
  23. if($login->validate() && $login->login())
  24. $this->redirect('/telephone/add');
  25. }
  26.  
  27. }
  28. else
  29. {
  30. return $this->render('register');
  31. }
  32. }
  33.  
  34. <div class="container">
  35. <div class="row">
  36. <h2> New User Signup</h2><br>
  37. <form class="formclass" method="POST" action="<?php echo Yii::$app->request->baseUrl;?>/telephone/signup/" role="form" id="register-form" novalidate="novalidate">
  38. <label> UserName:</label> <input type="name" name="username" id="username" placeholder="UserName" required><br><br>
  39. <label> Password: </label> <input type="password" name="password" id="password" placeholder="Password" required><br><br>
  40. <button type="submit" class="btn btn-default">Sign Up</button><BR><BR>
  41. </form>
  42.  
  43. </div>
  44. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement