Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> potrzeba szybkiej pomocy
vladyslavus
post
Post #1





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 3.03.2016

Ostrzeżenie: (0%)
-----


mam następujący błąd przy próbie rejestracji :
Notice: undefined variable: registerForm in var.../UserController.php in line 63
Fatalerror: Call to a member function is valid() on a non-object in..../UserController.php in line 63

a linia 63 to :

if ($registerForm->isValid($postVars))

jak to naprawić ?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
vladyslavus
post
Post #2





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 3.03.2016

Ostrzeżenie: (0%)
-----



  1. class UserController extends Zend_Controller_Action
  2. {
  3.  
  4. public function checkLogged()
  5. {
  6. if (!Application_Model_LoggedUser::isLogged())
  7. {
  8. Application_Message::getInstance()->addError('Użytkownik nie zalogowany');
  9. $this->_redirect($this->_helper->url('index', 'index', null, array(), true));
  10. }
  11. }
  12.  
  13. public function getServerName()
  14. {
  15. return '78.46.51.139';
  16. }
  17.  
  18. public function init()
  19. {
  20. /* Initialize action controller here */
  21. }
  22.  
  23. public function indexAction()
  24. {
  25. // action body
  26. }
  27.  
  28. public function activateAction()
  29. {
  30. $userId = $this->_getParam('id', null);
  31. $token = $this->_getParam('token', null);
  32.  
  33. if (is_null($userId) || is_null($token))
  34. {
  35. Application_Message::getInstance()->addError('Nie poprawne parametry aktywacyjne');
  36. $this->_redirect($this->_helper->url('index', 'index'));
  37. }
  38.  
  39. $userModel = new Application_Model_User();
  40.  
  41. $result = $userModel->activate($userId, $token);
  42.  
  43. if ($result == true)
  44. {
  45. Application_Message::getInstance()->addSuccess('Twoje konto zostało aktywowane. Zaloguj się by korzystać z serwisu.');
  46. $this->_redirect($this->_helper->url('index', 'index'));
  47. } else
  48.  
  49. {
  50. Application_Message::getInstance()->addError($result);
  51. $this->_redirect($this->_helper->url('index', 'index'));
  52. }
  53. }
  54.  
  55. public function registerAction()
  56. {
  57. if ($this->getRequest()->isPost())
  58. {
  59. $postVars = $this->getRequest()->getPost();
  60. if (isset($postVars['registersubmit']))
  61. {
  62. if empty($registerForm->isValid($postVars))
  63. {
  64. die('t');
  65. }
  66. }
  67.  
  68. $this->view->rolldownRegister = true;
  69.  
  70. $this->_forward('index', 'index');
  71.  
  72. return;
  73. $staticPageModel = new Application_Model_StaticPage();
  74. $registerForm = new Application_Form_UserRegister();
  75. $loginForm = new Application_Form_UserLogin();
  76. $forgotPasswordForm = new Application_Form_UserForgotPassword();
  77.  
  78.  
  79. if ($this->getRequest()->isPost())
  80. {
  81. $postVars = $this->getRequest()->getPost();
  82. if (isset($postVars['registersubmit']))
  83. {
  84. if ($registerForm->isValid($postVars))
  85. {
  86. $userModel = new Application_Model_User();
  87. if (( $result = $userModel->register($postVars) ) === true)
  88. {
  89. Application_Message::getInstance()->addSuccess('Konto zostało utworzone. Aby je aktywować postępuj według instrukcji z listu, który wysłaliśmy. Jeśli nie otrzymałeś listu sprawdź proszę folder SPAM');}
  90. $this->_redirect($this->_helper->url('index', 'index'));
  91. } else
  92. {
  93. Application_Message::getInstance()->addError($result);
  94. }
  95. } else {
  96.  
  97. print_r($registerForm);
  98. die;
  99. }
  100. }
  101. if (isset($postVars['loginsubmit']))
  102. {
  103. if ($loginForm->isValid($postVars))
  104. {
  105. $userModel = new Application_Model_User();
  106. if (( $result = $userModel->login($postVars['userName'], $postVars['password']) ) === true)
  107. {
  108. Application_Message::getInstance()->addSuccess('Zostałeś zalogowany');
  109. $this->_redirect($this->_helper->url('index', 'index'));
  110. } else
  111. {
  112. Application_Message::getInstance()->addError($result);
  113. }
  114. }
  115. }
  116. if (isset($postVars['forgotpasswordsubmit']))
  117. if ($forgotPasswordForm->isValid($postVars))
  118. {
  119. $userModel = new Application_Model_User();
  120. if (( $result = $userModel->recoverPassword($postVars['email']) ) === true)
  121. {
  122. Application_Message::getInstance()->addSuccess('Instrukcje dotyczące odzyskania hasła zostały wysłane na podany adres e-mail');
  123. $this->_redirect($this->_helper->url('index', 'index'));
  124. } else
  125. {
  126. Application_Message::getInstance()->addError($result);
  127. }
  128. }
  129. }
  130. }
  131.  
  132. $fragment = $staticPageModel->getStaticFragmentByFragmentName('rejestracja_kolumna');
  133. $this->view->staticpagetitle = $fragment->title;
  134. $this->view->staticpagecontent = $fragment->content;
  135. $this->view->regform = $registerForm;
  136. $this->view->loginform = $loginForm;
  137. $this->view->forgotpasswordform = $forgotPasswordForm;
  138. }
  139.  
  140. public function logoutAction()
  141. {
  142. $userModel = new Application_Model_User();
  143. if ($userModel->logout())
  144. {
  145. Application_Message::getInstance()->addSuccess('Pomyślnie wylogowano');
  146. } else
  147. {
  148. Application_Message::getInstance()->addError('Błąd podczas wylogowywania');
  149. }
  150. $this->_redirect($this->_helper->url('index', 'index'));
  151. }
  152.  
  153. public function loginAction()
  154. {
  155. if ($this->getRequest()->isPost())
  156. {
  157. $postVars = $this->getRequest()->getPost();
  158. $userModel = new Application_Model_User();
  159. if (isset($postVars['remember']))
  160. {
  161. $rememberUser = true;
  162. } else
  163. {
  164. $rememberUser = false;
  165. }
  166. if (( $result = $userModel->login($postVars['username'], $postVars['password'], $rememberUser) ) === true)
  167. {
  168. Application_Message::getInstance()->addSuccess('Zostałeś zalogowany');
  169. $this->_redirect($this->_helper->url('index', 'index'));
  170. } else
  171. {
  172. Application_Message::getInstance()->addError($result);
  173. }
  174. }
  175. $this->_redirect($this->_helper->url('index', 'index'));
  176. }
  177.  
  178. public function profileAction()
  179. {
  180. $this->checkLogged();
  181.  
  182. $this->view->rolldownProfile = true;
  183.  
  184. $this->_forward('index', 'index');
  185.  
  186. return;
  187.  
  188. $creditModel = new Application_Model_Credit();
  189. $staticPageModel = new Application_Model_StaticPage();
  190. $userChangePasswordForm = new Application_Form_UserChangePassword();
  191.  
  192. if ($this->getRequest()->isPost())
  193. {
  194. $formVars = $this->getRequest()->getPost();
  195. if (isset($formVars['changepasswordnsubmit']))
  196. {
  197. if ($userChangePasswordForm->isValid($formVars))
  198. {
  199. $user = new Application_Model_User();
  200. if (( $result = $user->changePassword($formVars) ) === true)
  201. {
  202. Application_Message::getInstance()->addSuccess('Hasło zostało zmienione');
  203. $this->_redirect($this->_helper->url('profile', 'user'));
  204. } else
  205. {
  206. Application_Message::getInstance()->addError($result);
  207. }
  208. }
  209. }
  210.  
  211. $creditsFragment = $staticPageModel->getStaticFragmentByFragmentName('profil_kredyty');
  212. $partnerFragment = $staticPageModel->getStaticFragmentByFragmentName('profil_partner');
  213.  
  214. $this->view->credits = $creditModel->getCreditsOptions();
  215. $this->view->smscredits = $creditModel->getSmsCreditsOptions();
  216. $this->view->changepasswordform = $userChangePasswordForm;
  217. $this->view->staticcredits = $creditsFragment->content;
  218. $this->view->staticpartnership = $partnerFragment->content;
  219. // action body
  220. }
  221.  
  222. public function creditsAction()
  223. {
  224. $this->checkLogged();
  225.  
  226. $creditModel = new Application_Model_Credit();
  227.  
  228. $this->view->credits = $creditModel->getCreditsOptions();
  229. $this->view->yeticredits = $creditModel->getYetiCreditsOptions();
  230. $this->view->smscredits = $creditModel->getSmsCreditsOptions();
  231. }
  232.  
  233. public function templateremoveAction()
  234. {
  235. $this->checkLogged();
  236.  
  237. $entryId = $this->_getParam('entryId');
  238.  
  239. if (is_null($entryId))
  240. {
  241. Application_Message::getInstance()->addError('Niepoprawne wywołanie');
  242. $this->_redirect($this->_helper->url('template', 'user', null, array(), true));
  243. }
  244.  
  245. $user = new Application_Model_User();
  246.  
  247. $result = $user->removeShowTemplateEntry($entryId);
  248.  
  249. if ($result !== true)
  250. {
  251. Application_Message::getInstance()->addError($result);
  252. } else
  253. {
  254. Application_Message::getInstance()->addSuccess('Pozycja została usunięta');
  255. }
  256.  
  257. $this->_redirect($this->_helper->url('template', 'user', null, array(), true));
  258. }
  259.  
  260. public function templateupAction()
  261. {
  262. $this->checkLogged();
  263.  
  264. $entryId = $this->_getParam('entryId');
  265.  
  266. if (is_null($entryId))

( dalej jest kod ale się nie zmieścił

Ten post edytował vladyslavus 3.03.2016, 15:40:30
Go to the top of the page
+Quote Post

Posty w temacie
- vladyslavus   potrzeba szybkiej pomocy   3.03.2016, 14:51:30
- - phpion   Pokaż więcej kodu, gdzie i jak inicjujesz $re...   3.03.2016, 14:53:52
- - vladyslavus   [PHP] pobierz, plaintext class UserController exte...   3.03.2016, 15:15:43
- - Rysh   1. Tytuł tematu do poprawy. 2. Kod umieszczamy w [...   3.03.2016, 15:20:51
- - com   użyj bb tagi   3.03.2016, 15:23:01
- - vladyslavus   oki to następnym arzem bee wiedział. To gdzie to m...   3.03.2016, 15:28:11
|- - Rysh   Cytat(vladyslavus @ 3.03.2016, 15:28...   3.03.2016, 15:29:28
- - viking   W registerAction() nigdzie nie tworzysz $regi...   3.03.2016, 15:28:51
- - com   [PHP] pobierz, plaintext $registerForm = new Appli...   3.03.2016, 15:35:51
- - vladyslavus   czyli ? jaką dokładnie linię mam umieścić ? zamias...   3.03.2016, 15:39:20
- - phpion   Na samym początku registerAction daj $registe...   3.03.2016, 15:48:13
- - com   tam masz sporo kodu który się nie wykona, zgłoś si...   3.03.2016, 15:49:23
- - Rysh   Cytat(vladyslavus @ 3.03.2016, 15:39...   3.03.2016, 15:56:14
- - vladyslavus   a w którym mam dac ? a da się to jakoś poprawić c...   3.03.2016, 16:20:20
- - Kshyhoo   Cytat(Rysh @ 3.03.2016, 15:20:51 ) 1....   3.03.2016, 17:59:31
- - com   Kshyhoo ok, ale dobrze, że ktoś czuwa jak Ciebie n...   3.03.2016, 18:16:37
|- - Kshyhoo   Cytat(com @ 3.03.2016, 18:16:37 ) Ksh...   3.03.2016, 18:20:11
- - vladyslavus   i wyskakuje błąd 9 cały czas: Parse error: syntax ...   3.03.2016, 22:03:42
- - Kshyhoo   Ostatnia prośba o zmianę tytułu na zgodny z zasada...   3.03.2016, 22:16:04
- - vladyslavus   a jak się tu to robi ?   3.03.2016, 22:18:19


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 17.10.2025 - 19:29