Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [HTML][MySQL][PHP]bład w kodzie rejestracji, HELP
Karol346
post 12.01.2012, 20:48:26
Post #1





Grupa: Zarejestrowani
Postów: 19
Pomógł: 0
Dołączył: 11.12.2011

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


Witam mam rejestracje i logowanie ale sa chyba błedy w kodzie
co źle w rejestracji ?
otóz mozna miec X kont na 1 email , a warunek jest ze tylko 1
po 2 mozna miec X kont na 1 nick , a warunek jest ze tylko 1
po 3 hasla moga byc rozne , konto zostanie zalozone , a w tabelki wprawadzi sie 1
oto kod :
  1. <html>
  2. <head>
  3. <title>Rejestracja</title>
  4. <meta http-equiv="content-type" content="text/html; charset=iso-8859-2" />
  5. <meta http-equiv="content-language" content="pl">
  6. </head>
  7.  
  8. <body>
  9. <form action="" method="POST">
  10.  
  11. <b>Nick: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b> <input type="text" name="username" /><i>&nbsp;&nbsp; Potrzebny aby się zalogować na konto.</i> <br></br>
  12. <b>Hasło: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b><input type="password" name="haslo" /> <i>&nbsp;&nbsp; Zapamiętaj je i nie podawaj <u>nikomu</u>, Administracja nigdy nie będzie cię prosić o hasło.</i><br></br>
  13. <b>Powtórz hasło:&nbsp;&nbsp;&nbsp;&nbsp;</b> <input type="password" name="haslo2" /> <br> </br>
  14. <b>E-mail: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b> <input type="email" name="email" /> <i>&nbsp;&nbsp; Wymagane do weryfikacji konta.</i>
  15. </br>
  16. </br>
  17. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  18. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  19. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  20. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  21. <input type="submit" value="Zarejestruj się." /> </br>
  22.  
  23. </form>
  24. Lub jeśli masz już konto <a href="logowanie.php"/><font color="blue"/>Zaloguj się !</font></a>
  25. </body>
  26.  
  27. </html>
  28.  
  29. <?php
  30. include ('db.php');
  31.  
  32. $name = $_POST['username'];
  33. $password = $_POST['haslo'];
  34. $password2 = $_POST['haslo'];
  35. $email = $_POST['email'];
  36.  
  37. if($name != NULL and $password !=NULL and $email!=NULL){
  38.  
  39. $mysql = mysql_fetch_array(mysql_query("select username from reg where username = $name"));
  40. $mysql2 = mysql_fetch_array(mysql_query("select email from reg where email = $email"));
  41. if($mysql2['email'] == null){
  42. echo"Podany adres email został już zarejestrowany!!";
  43. }elseif($mysql['username'] == null){
  44. echo"Podany nick jest już zarejestrowany!!";
  45. }elseif($password == $password2){
  46. $rejestracja = "insert into `reg` (`username`, `email`, `haslo`) VALUES ('$name', '$email', '$password')";
  47. $rejestracja2 = mysql_query($rejestracja);
  48. if($rejestracja2){
  49. echo "Zostałeś poprawnie zarejestrowany";
  50. }else{
  51. echo"ups.. wystąpił jakiś problem sprubuj ponownie za chwile";
  52. }
  53. }else{
  54. echo"Podałeś róźne hasła!!";
  55. }
  56. }
  57. ?>


a w logowaniu jest prawie OK tyle ze po zalogowaniu chce aby przenosiło do pages/index.php (gdy dobre dane) jasli złe komunikat popraw dane
oto kod
  1. <html>
  2. <head>
  3. <title>Logownie</title>
  4. <meta http-equiv="content-type" content="text/html"; charset="iso-8859-2" />
  5. <meta http-equiv="content-language" content="pl">
  6.  
  7. <style type="text/css">
  8. .log {
  9. margin-left:15px;
  10. margin-top:40px;
  11. background-color:red;
  12. width:600;
  13. height:72;
  14. }
  15.  
  16. .zaloguj {
  17. margin-left:20px;
  18. }
  19.  
  20.  
  21. </style>
  22.  
  23. </head>
  24. <body>
  25. <font size="25" color="blue"/> </br>Logowanie</font>
  26. <form action="logowanie.php" method="POST" class="log">
  27. <b>Login:</b>&nbsp;&nbsp <input type="text" name="username"/><!--</br>--><input class="zaloguj" name="loguj" type="submit" value="Zaloguj" /></br>
  28. <b>Hasło:</b>&nbsp;&nbsp <input type="password" name="haslo"/></br></br>
  29. <!-- <input class="zaloguj" name="loguj" type="submit" value="Zaloguj" /></br>-->
  30. <a href="rejestracja.php" /><font color="yellow"/>Jeśli nie posiadasz konta załóż je Za Darmo</font> </a>
  31. </form>
  32. </body>
  33. </html>
  34.  
  35. <?php
  36. include ('db.php');
  37. $login = $_POST['username'];
  38. $pass = $_POST['haslo'];
  39.  
  40. if($login!=null and $pass!=null){
  41. $mysql = mysql_fetch_array(mysql_query("select user_id from `reg` where `username` = '$login' AND `haslo` = '$pass' limit 1"));
  42. if($mysql == NULL){
  43. echo'<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>';
  44. include "menu/stopka.php";
  45. echo "<script type='text/javascript'>window.alert('Błędne haslo u/lub login'):Document.location.href = 'index.php';</script>";
  46. }elseif($mysql != NULL){
  47. $_SESSION['zalogowany'] = true;
  48. $_SESSION['username'] = $_POST['username'];
  49. $_SESSION['haslo'] = $_POST['haslo'];
  50. echo "Jesteś zalogowany.";
  51. header("Location: 1/index2.php");
  52. }
  53. }
  54. ?>


Dziękuje z góry smile.gif
Go to the top of the page
+Quote Post

Posty w temacie


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:24