Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [HTML][PHP] Problem z rejestracją.
patrasek
post
Post #1





Grupa: Zarejestrowani
Postów: 4
Pomógł: 0
Dołączył: 18.01.2015

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


Witam. Mam problem z rejestracją, a mianowicie nie dodaje rekordów do bazy.

register.php
  1. <?php
  2.  
  3. if($_POST['REGISTER'])
  4. {
  5.  
  6. $Name = $Core->ClearText($_POST['NAME']);
  7. $Mail = $Core->ClearText($_POST['MAIL']);
  8. $Pass = $Core->ClearText($_POST['PASS']);
  9.  
  10. if(!$Name || !$Mail || !$Pass)
  11. {
  12.  
  13. $View->Load("info");
  14. $View->Add("title", "Błąd :: Puste pola");
  15. $View->Add("header", "Błąd! Puste pola!");
  16. $View->Add("info", "Pola formularza nie mogą być puste!");
  17. $View->Add("back", "register.html");
  18. $View->Out();
  19.  
  20. }
  21.  
  22. else
  23. {
  24.  
  25. if(!filter_var($Mail, FILTER_VALIDATE_EMAIL))
  26. {
  27.  
  28. $View->Load("info");
  29. $View->Add("title", "Błąd :: Błędny e-mail");
  30. $View->Add("header", "Błąd! Błędny e-mail!");
  31. $View->Add("info", "Podałeś błędny adres e-mail!");
  32. $View->Add("back", "register.html");
  33. $View->Out();
  34.  
  35. }
  36.  
  37. else
  38. {
  39.  
  40. $Query = $MySQL->prepare("SELECT * FROM `users` WHERE `mail`=:three");
  41.  
  42. $Query->bindValue(":three", $Mail, PDO::PARAM_STR);
  43.  
  44. $Query->execute();
  45.  
  46. if($Query->rowCount() > 0)
  47. {
  48.  
  49. $View->Load("info");
  50. $View->Add("title", "Błąd :: Zajęty adres e-mail");
  51. $View->Add("header", "Błąd! Zajęty adres e-mail!");
  52. $View->Add("info", "Taki adres e-mail już istnieje w naszej bazie danych!");
  53. $View->Add("back", "register.html");
  54. $View->Out();
  55.  
  56. }
  57.  
  58. else
  59. {
  60.  
  61. $Query = $MySQL->prepare("SELECT * FROM `users` WHERE `login`=:one");
  62.  
  63. $Query->bindValue(":one", $Name, PDO::PARAM_STR);
  64.  
  65. $Query->execute();
  66.  
  67. if($Query->rowCount() > 0)
  68. {
  69.  
  70. $View->Load("info");
  71. $View->Add("title", "Błąd :: Zajęty login");
  72. $View->Add("header", "Błąd! Zajęty login!");
  73. $View->Add("info", "Taki login już istnieje w naszej bazie danych!");
  74. $View->Add("back", "register.html");
  75. $View->Out();
  76.  
  77. }
  78. else
  79. {
  80.  
  81. $Query = $MySQL->prepare("SELECT * FROM `users` WHERE `pass`=:two");
  82.  
  83. $Query->bindValue(":two", sha1(md5($Pass)), PDO::PARAM_STR);
  84.  
  85. $Query->execute();
  86.  
  87.  
  88. else
  89. {
  90.  
  91. $Query = $MySQL->prepare("INSERT INTO `users` VALUES('', :one, :two, '0', '0', :three)");
  92.  
  93. $Query->bindValue(":one", $Name, PDO::PARAM_STR);
  94. $Query->bindValue(":two", sha1(md5($Pass)), PDO::PARAM_STR);
  95. $Query->bindValue(":three", $Mail, PDO::PARAM_STR);
  96.  
  97. $Query->execute();
  98.  
  99. $View->Load("info");
  100. $View->Add("title", "Zarejestrowano");
  101. $View->Add("header", "Zostałeś poprawnie zarejestrowany!");
  102. $View->Add("info", "Rejestracja przebiegła pomyślnie!");
  103. $View->Add("back", "login.html");
  104. $View->Out();
  105.  
  106. }
  107. }
  108. }
  109.  
  110. }
  111.  
  112. }
  113.  
  114. }
  115.  
  116. else
  117. {
  118.  
  119. $View->Load("register");
  120. $View->Out();
  121.  
  122. }
  123.  
  124. ?>

Oraz register.html
...
  1. <p><form method="post" action="./model/quest/register.php">
  2.  
  3. <input type="hidden" name="REGISTER" value="true">
  4.  
  5. <br><input type="text" name="NAME" placeholder="Login"><br>
  6. <br><input type="password" name="PASS" placeholder="Hasło"><br>
  7. <br><input type="text" name="MAIL" placeholder="E-mail"><br>
  8.  
  9. <br><button type="submit" class="przycisk">Zarejestruj <i class="fa fa-chevron-circle-right"></i> </button>
  10.  
  11. </form></p>



Proszę o sprawdzenie.

Ten post edytował patrasek 30.01.2015, 21:56:10
Go to the top of the page
+Quote Post
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Temat: Jak poprawnie zada pytanie
Masz tam napisane jak samodzielnie analizować tak proste problemy.


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

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 Aktualny czas: 20.08.2025 - 09:27