Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: potrzeba szybkiej pomocy
Forum PHP.pl > Forum > PHP
vladyslavus
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ć ?
phpion
Pokaż więcej kodu, gdzie i jak inicjujesz $registerForm. Oba błędy dotyczą tego samego - zmienna $registerForm nie istnieje.
vladyslavus

  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ł
Rysh
1. Tytuł tematu do poprawy.
2. Kod umieszczamy w [php_] [/_php] bez _
com
użyj bb tagi
vladyslavus
oki to następnym arzem bee wiedział. To gdzie to mam wzrucić ? generalnie mogę udostępnic ftp jeśłi zajdzie potrzeba

czyli ? czego mam użyć ? w kodzie czy tu ?
viking
W registerAction() nigdzie nie tworzysz $registerForm. Powinno być przed isPost.
Rysh
Cytat(vladyslavus @ 3.03.2016, 15:28:11 ) *
oki to następnym arzem bee wiedział. To gdzie to mam wzrucić ? generalnie mogę udostępnic ftp jeśłi zajdzie potrzeba

czyli ? czego mam użyć ? w kodzie czy tu ?

Edytuj swój poprzedni post i umieść kod w odpowiednim tagu. Szybciej znajdziesz kogoś komu będzie się chciało przejrzeć ten kod.
com
  1. $registerForm = new Application_Form_UserRegister();

Tworzysz to w złym miejscu smile.gif
vladyslavus
czyli ? jaką dokładnie linię mam umieścić ? zamiast register action dać register form czy jak ?
phpion
Na samym początku registerAction daj $registerForm = new Application_Form_UserRegister() czyli przenieś go z linii 74 do 56.
com
tam masz sporo kodu który się nie wykona, zgłoś się może do autora, żeby to poprawił smile.gif
Rysh
Cytat(vladyslavus @ 3.03.2016, 15:39:20 ) *
czyli ? jaką dokładnie linię mam umieścić ? zamiast register action dać register form czy jak ?


Cytat(com @ 3.03.2016, 15:49:23 ) *
tam masz sporo kodu który się nie wykona, zgłoś się może do autora, żeby to poprawił smile.gif


Tak jak pisze com, masz tam kod który się nie wykona - ponieważ dajesz return w pewnym momencie, co oznacza w tym wypadku zakończ działanie metody.
vladyslavus
a w którym mam dac ?

a da się to jakoś poprawić czy muszę się zgłosić do autora kodu?

skasowac return ?
Kshyhoo
Cytat(Rysh @ 3.03.2016, 15:20:51 ) *
1. Tytuł tematu do poprawy.
2. Kod umieszczamy w [php_] [/_php] bez _

Nie bawimy się w moderatorów.

Do autora: proszę poprawić tytuł wątku na zgodny z zasadami działu.
com
Kshyhoo ok, ale dobrze, że ktoś czuwa jak Ciebie nie było, bo ten kod był tak długi ze nie dało sie go czytać bez bbcode, zresztą moderator nie miał zastrzeżen tongue.gif

vladyslavus da sie ale nikt nie wie jaki był jego zamysł jak to tworzył, bo tam jest w jeden metodzie kilka akcji które robią niby to samo i nie wiadomo czemu i poco wink.gif
Kshyhoo
Cytat(com @ 3.03.2016, 18:16:37 ) *
Kshyhoo ok, ale dobrze, że ktoś czuwa jak Ciebie nie było, bo ten kod był tak długi ze nie dało sie go czytać bez bbcode, zresztą moderator nie miał zastrzeżen tongue.gif

Po to jest opcja raportowania. Po za tym, mógł mu udzielić porady w poście i nikt by się nie czepił...
vladyslavus

i wyskakuje błąd 9 cały czas:
Parse error: syntax error, unexpected 'if' (T_IF) in /var/www/peep-show.tv/application/controllers/UserController.php on line 59

ktos chętny : mogę udzielić dostępu do serweru żeby naprawić ten bład rejestracji - chętnie zapłacę nawet w tej chwili
Kshyhoo
Ostatnia prośba o zmianę tytułu na zgodny z zasadami...
vladyslavus
a jak się tu to robi ?
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.