Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP][MYSQL] Problem z przypomianiem hasła...
-Jercddd-
post 31.05.2008, 19:22:30
Post #1





Goście







Mam problem z przypominaniem hasła. Niby jest wszystko ok bo sprawdza czy taki nick i mail istnieje w bazie ale jak już chcę sprawdzić czy e-mail jest przypisany do tego nicku to jak podam jakiś mail ale nie tego samego użytkownika, ale użytkownika innego, ale który istnieje w bazie to dalej wysyła hasło. Co z tym zrobić ? Kod:

  1. <?php 
  2.  
  3. mysql_connect ('localhost','root','some');
  4.  
  5. $email= mysql_query ("SELECT user FROM base WHERE user='".trim($_POST['nick'])."'");
  6. $nick= mysql_query ("SELECT email FROM base WHERE email='".trim($_POST['email'])."'");
  7. $chmailnick= mysql_query ("SELECT email,user FROM base WHERE email='".trim($_POST['email'])."' AND 
  8. user='".trim($_POST['nick'])."'");
  9. $chemail= mysql_fetch_assoc($email);
  10. $chnick= mysql_fetch_assoc($nick);
  11.  
  12. if (!empty($_POST['email']) && !empty($_POST['nick'])) {
  13.  
  14. if ($chemail > 1 && $chnick > 1 && $chemail = $chnick) {
  15.  
  16. $mail= $_POST['email'];
  17. $password= mysql_query("SELECT password FROM `base` WHERE `email`='".$_POST['email']."'");
  18. $subject= 'Forgotten password';
  19. $message= 'Yo, Your nick is: ' . $nick . 'Password: ' . $password;
  20. $header= 'From: example@example.com';
  21.  
  22. mail ($mail, $subject, $message, $header);
  23.  
  24. echo 'Password has been sent :)';
  25.  
  26. }
  27.  
  28. else {
  29.  
  30. if ($chemail < 1) {
  31.  
  32. echo 'E-mail does not exist in the base';
  33.  
  34. }
  35.  
  36. if ($chnick < 1) {
  37. echo 'Nick does not exist in the base';
  38. }
  39.  
  40. if ($chnick != $chemail) {
  41. echo 'E-mail does not fit to Nick';
  42. }
  43.  
  44. }
  45.  
  46. }
  47.  
  48.  
  49.  
  50. else {
  51. echo 'Type all information';
  52. }
  53.  
  54. ?>


  1. <!DOCTYPE html
  2. PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
  5. <meta http-equiv="Content-type" content="application/xhtml+xml; charset=iso-8859-2" />
  6. <meta name="Description" content="Something" />
  7. <meta name="Keywords" content="Something" />
  8. <meta name="Author" content="Author " />
  9. <link rel="Stylesheet" href="style.css" type="text/css" />
  10. <title>Title</title>
  11. </head>
  12.  
  13. <form action="remind.php" method="post">
  14. <div id="remind">
  15. E-mail: <input type="text" name="email" />
  16. Nick: <input type="text" name="nick" />
  17. <input type="submit" value="Send" />
  18. </div>
  19. </form>
  20.  
  21.  
  22. </body>
  23. </html>
Go to the top of the page
+Quote Post
nospor
post 31.05.2008, 19:29:32
Post #2





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




nie: $chemail = $chnick
a: $chemail == $chnick

Robisz chyba porównanie a nie przypisanie, nie ? winksmiley.jpg

pozatym czemu robisz 3 zapytania na pobranie nicka i maila? czemu nie robisz tego jednym? Gdzies tu jest haczyk?


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

"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 Wersja Lo-Fi Aktualny czas: 25.06.2025 - 15:05