Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] OOP problem z klasą rejestracji, jw
miras
post 22.04.2013, 16:58:15
Post #1





Grupa: Zarejestrowani
Postów: 1 004
Pomógł: 9
Dołączył: 18.01.2011
Skąd: Siedlce

Ostrzeżenie: (30%)
XX---


Witam, mam klasę, która w przyszłości ma rejestrować użytkowników:

  1.  
  2. class Register extends Connect {
  3. public $error;
  4. public $success;
  5. public $imie,$nazwisko,$telefon,$mail,$haslo,$vhaslo;
  6. public function add() {
  7. $this->imie = $_POST['imie'];
  8. $this->nazwisko = $_POST['nazwisko'];
  9. $this->telefon = $_POST['telefon'];
  10. $this->mail = $_POST['email'];
  11. $this->haslo = $_POST['haslo'];
  12. $this->vhaslo = $_POST['vhaslo'];
  13. }
  14.  
  15. public function check() {
  16. include("language/pl.php");
  17. if (!empty($_POST['sprawdz'])) {
  18. if ((!empty($_POST['imie'])) && (!empty($_POST['nazwisko'])) && (!empty($_POST['email'])) && (!empty($_POST['haslo']))) {
  19. if ($_POST['haslo']==$_POST['vhaslo']) {
  20. $this->success=$lang[2];
  21. } else { $this->error=$lang[1]; }
  22. } else { $this->error=$lang[0]; }
  23. }
  24. return $this->error;
  25. }
  26.  
  27. }


jednak wywala mi błędy:

  1.  
  2. Notice: Undefined index: imie in C:\xampp-portable\htdocs\vishop\class\shop.php on line 23
  3.  
  4. Notice: Undefined index: nazwisko in C:\xampp-portable\htdocs\vishop\class\shop.php on line 24
  5.  
  6. Notice: Undefined index: telefon in C:\xampp-portable\htdocs\vishop\class\shop.php on line 25
  7.  
  8. Notice: Undefined index: email in C:\xampp-portable\htdocs\vishop\class\shop.php on line 26
  9.  
  10. Notice: Undefined index: haslo in C:\xampp-portable\htdocs\vishop\class\shop.php on line 27
  11.  
  12. Notice: Undefined index: vhaslo in C:\xampp-portable\htdocs\vishop\class\shop.php on line 28


--------------------
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 3)
sajegib
post 22.04.2013, 17:01:59
Post #2





Grupa: Zarejestrowani
Postów: 352
Pomógł: 59
Dołączył: 16.01.2013

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


Najwyraźniej nie przesyłasz wartości metodą POST, masz źle ustawione indeksy lub formularz
Go to the top of the page
+Quote Post
miras
post 22.04.2013, 17:06:13
Post #3





Grupa: Zarejestrowani
Postów: 1 004
Pomógł: 9
Dołączył: 18.01.2011
Skąd: Siedlce

Ostrzeżenie: (30%)
XX---


Plik register.php:


  1.  
  2. <?php
  3. $register = new Register;
  4. $register->add();
  5. $register->check();
  6. ?>
  7.  
  8. <form method="POST" action="">
  9. <table align="center">
  10. <tr><td> Imię </td><td><input type="text" name="imie" value=""/></td></tr>
  11. <tr><td> Nazwisko </td><td><input type="text" name="nazwisko" value=""/></td></tr>
  12. <tr><td> Telefon </td><td><input type="text" name="telefon" value=""/></td></tr>
  13. <tr><td> E-mail </td><td><input type="text" name="email" value=""/></td></tr>
  14. <tr><td> Hasło </td><td><input type="text" name="haslo" value=""/></td></tr>
  15. <tr><td> vhaslo </td><td><input type="text" name="vhaslo" value=""/></td></tr>
  16. </table>
  17. <input type="hidden" name="sprawdz" value="1"/>
  18. <br> <center><input type="submit" value="Wyślij"/></center>
  19. </form>


Ehh, miałeś racje smile.gif, poradziłem, dzięki.


--------------------
Go to the top of the page
+Quote Post
sajegib
post 22.04.2013, 17:21:54
Post #4





Grupa: Zarejestrowani
Postów: 352
Pomógł: 59
Dołączył: 16.01.2013

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


Musisz zacząć rozumieć uwagi i ostrzeżenia które PHP ci wywala na ekran, będzie ci łatwiej pracować wink.gif

powodzenia!
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 03:23