Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php][mysql] Rejestracja sprawdzenie czy hasła są równe
jacus24
post
Post #1





Grupa: Zarejestrowani
Postów: 133
Pomógł: 0
Dołączył: 15.12.2007

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


Witam mam taki skrypt rejestracji wktórym chce zrobić żeby sprawdzało czy podane hasło = hasło_2 i jeżeli nie będzie równe to informowało by że wpisane hasła nie są takie same. Jak mogę to zrobić?
  1. <?php
  2. include "conn.inc.php";
  3. ?>
  4.  
  5. <html>
  6. <head>
  7. <meta http-equiv="Content-type" content="text/html; charset=iso-8859-2" />
  8. <meta name="Keywords" content="" />
  9. <meta name="Description" content=" " />
  10. <title>IMGAY - Rejestracja</title>
  11. </head>
  12. <body>
  13. <?php
  14.  if (isset($_POST['submit']) && $_POST['submit'] == "Zarejestruj") {
  15.  if ($_POST['login'] != "" &&
  16. $_POST['haslo'] != "" &&
  17. $_POST['haslo_2'] != "" &&
  18. $_POST['email'] !== "" ) {
  19.  
  20. $query = "SELECT login, haslo FROM uzytkownicy WHERE login = '".$_POST['login']."' AND haslo = '".$_POST['haslo']."'";
  21. $result = mysql_query($query) or die(mysql_error());
  22.  
  23. if (mysql_num_rows($result) != 0) {
  24. ?>
  25. <font color="#FF0000"><b>Nazwa użytkownika
  26. <?php echo $_POST['login']; ?>jest już używana. Proszę wybrać inną</b></font>
  27.  
  28. <form action="rejestracja.php" method="post">
  29. Login <input type="text" name="login" size="30" maxlength="40">
  30. Hasło <input type="password" name="haslo" size="30" maxlength="40">
  31. Powtórz hasło <input type="password" name="haslo_2" size="30" maxlength="40" >
  32. Email <input type="text" name="email" size="30" maxlength="40" ></p>
  33. <input type="checkbox" name="regulamin" value="tak" > Akceptuję&nbsp;<a href="regulamin.php">regulamin</a>
  34. <?php $today = date("Y-m-d"); ?>
  35. <input type="submit" name="submit" value="Zarejestruj" > &nbsp;
  36. <input type="reset" value="Wyczyść">
  37. </form>
  38.  
  39. <?php 
  40.  } else {
  41.  
  42.  $query = "INSERT INTO `uzytkownicy` (login, haslo, haslo_2, email, today)
  43.  VALUES (
  44. '".$_POST['login']."',
  45. '".$_POST['haslo']."',
  46. '".$_POST['haslo_2']."',
  47. '".$_POST['email']."',
  48.  '".date("Y-m-d")."'
  49.  );";
  50.  
  51. if(mysql_query($query) == 1)
  52. {
  53. echo 'ok';
  54. }
  55. else
  56. {
  57. }
  58. $_SESSION['user_logged'] = $_POST['login'];
  59. $_SESSION['user_password'] = $_POST['haslo'];
  60. ?>
  61.  
  62. Dziękujemy, <?php echo $_POST['login'] . " " .
  63. $_POST['region']; ?> , za zarejestrowanie się!<br>
  64.  
  65. <?php
  66. header("Refresh: 5: URL=index.php");
  67. echo "Zakonczono proces rejestracji! " .
  68.  "Zostaniesz przeniesiony do oryginalnej strony!<br>";
  69. echo "(Jesli przegladarka nie obsluguje przekierowan, " .
  70.  "<a href=\"index.php\">kliknij tutaj</a>)";
  71. die();
  72. }
  73. } else {
  74. ?>
  75.  
  76. Proszę wypełnić wszystkie pola
  77. <form action="rejestracja.php" method="post">
  78. Login <input type="text" name="login" size="30" maxlength="40">
  79. Hasło <input type="password" name="haslo" size="30" maxlength="40">
  80. Powtórz hasło <input type="password" name="haslo_2" size="30" maxlength="40" >
  81. Email <input type="text" name="email" size="30" maxlength="40" ></p>
  82. <input type="checkbox" name="regulamin" value="tak" > Akceptuję&nbsp;<a href="regulamin.php">regulamin</a>
  83. <?php $today = date("Y-m-d"); ?>
  84. <input type="submit" name="submit" value="Zarejestruj" > &nbsp;
  85. <input type="reset" value="Wyczyść">
  86. </form>
  87.  
  88. <?php
  89.  }
  90. } else {
  91. ?>
  92.  
  93. <form action="rejestracja.php" method="post">
  94. Witamy na stronie rejestracji</p>
  95. Login <input type="text" name="login" size="30" maxlength="40">
  96. Hasło <input type="password" name="haslo" size="30" maxlength="40">
  97. Powtórz hasło <input type="password" name="haslo_2" size="30" maxlength="40" >
  98. Email <input type="text" name="email" size="30" maxlength="40" ></p>
  99. <input type="checkbox" name="regulamin" value="tak" > Akceptuję&nbsp;<a href="regulamin.php">regulamin</a>
  100. <?php $today = date("Y-m-d"); ?>
  101. <input type="submit" name="submit" value="Zarejestruj" > &nbsp;
  102. <input type="reset" value="Wyczyść">
  103. </form>
  104. <?php
  105. }
  106. ?>
  107. </body>
  108. </html>
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 2)
daris
post
Post #2





Grupa: Zarejestrowani
Postów: 78
Pomógł: 4
Dołączył: 7.01.2008

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


Zamień:
  1. <?php
  2. $_POST['haslo_2'] != "" &&
  3. ?>

na:
  1. <?php
  2. $_POST['haslo_2'] == $_POST['haslo'] &&
  3. ?>
Go to the top of the page
+Quote Post
jacus24
post
Post #3





Grupa: Zarejestrowani
Postów: 133
Pomógł: 0
Dołączył: 15.12.2007

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


Ok dzięki.
Go to the top of the page
+Quote Post

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: 24.12.2025 - 13:16