Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php][mysql]rejestracja sprawdzanie czy email już istnieje już w bazie
jacus24
post 31.03.2008, 17:05:52
Post #1





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

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


Mam taki kod rejestracji. Jak zrobić żeby sprawdzało czy dany email już istanieje i wyświetlało info o tym?
  1. <?php
  2.  if (isset($_POST['submit']) ) {
  3.  if ($_POST['login'] != "" &&
  4.  $_POST['haslo'] != "" &&
  5.  $_POST['haslo_2'] == $_POST['haslo'] &&
  6.  $_POST['regulamin'] != "" &&
  7.  $_POST['email'] !== "" ) {
  8. $query = "SELECT login, haslo FROM uzytkownicy WHERE login = '".$_POST['login']."' ";
  9. $result = mysql_query($query) or die(mysql_error());
  10.  
  11. if (mysql_num_rows($result) != 0) {
  12. Nazwa użytkownika<?php echo $_POST['login']; ?>jest już używana.
  13. <form action="rej.php" method="post">
  14. login<input type="text" name="login" size="20" maxlength="40">
  15. hasło<input type="password" name="haslo" size="20" maxlength="40">
  16. haslo2<input type="password" name="haslo_2" size="20" maxlength="40" >
  17. email<input type="text" name="email" size="20" maxlength="40" >
  18. <input type="submit" name="submit" value="Zarejestruj" >
  19. <?php
  20.  } else {
  21.  $query = "INSERT INTO `uzytkownicy` (login, haslo, haslo_2, email, today)
  22.  VALUES (
  23. '".$_POST['login']."',
  24. '".$_POST['haslo']."',
  25. '".$_POST['haslo_2']."',
  26. '".$_POST['email']."',
  27.  '".date("Y-m-d")."'
  28.  );";
  29.  
  30. if(mysql_query($query) == 1)
  31. {
  32. echo '';
  33. }
  34. else
  35. {
  36. }
  37. $_SESSION['user_logged'] = $_POST['login'];
  38. $_SESSION['user_password'] = $_POST['haslo'];
  39. ?>
  40. <?php
  41. header("Refresh: 5: URL=index.php");
  42. echo "Zakonczono proces rejestracji! " .
  43.  "Zostaniesz przeniesiony do oryginalnej strony!<br>";
  44. echo "(Jesli przegladarka nie obsluguje przekierowan, " .
  45.  "<a href=\"index.php\">kliknij tutaj</a>)";
  46. die();
  47. }
  48. } else {
  49. ?>
  50. <form action="rej.php" method="post">
  51. login<input type="text" name="login" size="20" maxlength="40">
  52. hasło<input type="password" name="haslo" size="20" maxlength="40">
  53. haslo2<input type="password" name="haslo_2" size="20" maxlength="40" >
  54. email<input type="text" name="email" size="20" maxlength="40" >
  55. <input type="submit" name="submit" value="Zarejestruj" >
  56. <?php
  57.  }
  58. } else {
  59.  
  60. ?>
  61. <form action="rej.php" method="post">
  62. login<input type="text" name="login" size="20" maxlength="40">
  63. hasło<input type="password" name="haslo" size="20" maxlength="40">
  64. haslo2<input type="password" name="haslo_2" size="20" maxlength="40" >
  65. email<input type="text" name="email" size="20" maxlength="40" >
  66. <input type="submit" name="submit" value="Zarejestruj" >
  67. <?php
  68.  
  69. } {
  70.  
  71. if ($_POST['haslo_2'] != $_POST['haslo'])
  72.  echo '<p align="center"><font color="red">Podane hasła są rózne</font></p>';
  73.  
  74. }
  75. ?>
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: 25.07.2025 - 07:54