Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

2 Stron V   1 2 >  
Reply to this topicStart new topic
> Problem . Przypomnienie Hasła.
JacobGames26
post 3.11.2013, 14:11:40
Post #1





Grupa: Zarejestrowani
Postów: 37
Pomógł: 0
Dołączył: 12.10.2013

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


Witam . Mam mały problem . Chodzi o przypomnienie hasła. Mam owy kod . Wysyla on na e-mail wiadomość z zmianą hasła ale kiedy wchodzę w owy kod nie działa. Wyskakuje błąd "Incorrect or used activation key." Nie wiem zbytnio jak naprawić ten problem.
O to jest kod przypominający hasło. :

  1. <?php
  2. require("config.php");
  3.  
  4. $email = mysql_real_escape_string(htmlspecialchars($_POST['email']));
  5. $domena = $_SERVER['HTTP_HOST'];
  6. $skrypt= $_SERVER['SCRIPT_NAME'];
  7. $parametry = $_SERVER['QUERY_STRING'];
  8. $address = $domena . $skrypt. '?' . $parametry;
  9. $headers = 'From: NADAWCA' . "\r\n" .
  10. 'Reply-To: NADAWCA' . "\r\n" .
  11. 'X-Mailer: PHP/' . phpversion();
  12.  
  13. if(isset($_GET['key'])) {
  14. }
  15. if(isset($key)) {
  16. $checkkey = 'SELECT * FROM users WHERE activation_key="'.$key.'"';
  17. $ck = mysql_fetch_row(mysql_query($checkkey));
  18. if(!$ck[1]) {
  19. Incorrect or used activation key.
  20. ';
  21. }
  22. }
  23. if(isset($key)) {
  24. $checkkey = 'SELECT * FROM users WHERE activation_key="'.$key.'"';
  25. $rekord = mysql_fetch_assoc(mysql_query($checkkey));
  26. $useremail = $rekord['email'];
  27. $new = uniqid();
  28. $newhash = sha1($new);
  29. $query = "UPDATE user SET password='".$newhash."' WHERE activation_key='".$key."';";
  30. mysql_query ($query);
  31. $to = ''.$useremail.'';
  32. $subject = 'New password';
  33. $message = 'Welcome , your current password: '.$new.'';
  34. mail($to, $subject, $message, $headers);
  35. $finish = "UPDATE user SET activation_key='0' WHERE email='".$useremail."';";
  36. mysql_query($finish);
  37. echo 'New password has been sent to specified email.';
  38. }
  39. if(empty($email)) {
  40. echo '<form method="post" action="#">
  41. Your Email: <input type="text" name="email"/>
  42. <input type="submit" value="Send password"/>';
  43. }
  44. if(isset($email) and !filter_var("$email", FILTER_VALIDATE_EMAIL)) {
  45. echo 'This email address is inncorect.';
  46. }
  47. if(isset($email)) {
  48. $checkemail = mysql_query('SELECT * FROM users WHERE email="'.$email.'"');
  49. $checkemail = mysql_fetch_row($checkemail);
  50. if(!$checkemail[1]) {
  51. The email does not exist in database..';
  52. }
  53. elseif($checkemail[1]) {
  54. $new = uniqid();
  55. $query = "UPDATE user SET activation_key='".$new."' WHERE email='".$email."';";
  56. mysql_query ($query);
  57. $to = ''.$email.'';
  58. $subject = 'New password';
  59. $message = 'Hi , if you want to change the password on: http://'.$address.'key='.$new.'';
  60. mail($to, $subject, $message, $headers) or die ("Can't send email");
  61. echo 'Information about the new password has been sent to your e-mail.';
  62. }
  63. }
  64. ?
>
Go to the top of the page
+Quote Post
jackraymund
post 3.11.2013, 16:03:07
Post #2





Grupa: Zarejestrowani
Postów: 217
Pomógł: 21
Dołączył: 10.06.2011
Skąd: Głogów

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


może te funkcje modyfikuja klucz?

sprawdź
  1. echo 'Incorrect or used activation key. '.$key;


--------------------
Wykonuje zlecenia na pobieranie danych ze stron i różne boty.
Go to the top of the page
+Quote Post
JacobGames26
post 3.11.2013, 16:12:59
Post #3





Grupa: Zarejestrowani
Postów: 37
Pomógł: 0
Dołączył: 12.10.2013

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


Wyskakuje taki błąd "Incorrect or used activation key. 527667c87fd3b".
Go to the top of the page
+Quote Post
com
post 3.11.2013, 16:16:55
Post #4





Grupa: Zarejestrowani
Postów: 3 034
Pomógł: 366
Dołączył: 24.05.2012

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


  1. var_dump($ck[1]);
Go to the top of the page
+Quote Post
JacobGames26
post 3.11.2013, 16:20:25
Post #5





Grupa: Zarejestrowani
Postów: 37
Pomógł: 0
Dołączył: 12.10.2013

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


Cytat(com @ 3.11.2013, 16:16:55 ) *
  1. var_dump($ck[1]);


I co ja mam z tym zrobić ?
Go to the top of the page
+Quote Post
com
post 3.11.2013, 16:22:33
Post #6





Grupa: Zarejestrowani
Postów: 3 034
Pomógł: 366
Dołączył: 24.05.2012

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


no wrzuć i sprawdzić co zwraca bo skoro wykonuje warunek:
  1. if(!$ck[1]) {
  2. Incorrect or used activation key.
  3. ';
  4. }

no to pewnie $ck[1] nie istnieje smile.gif
Go to the top of the page
+Quote Post
JacobGames26
post 3.11.2013, 16:23:59
Post #7





Grupa: Zarejestrowani
Postów: 37
Pomógł: 0
Dołączył: 12.10.2013

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


Cytat(com @ 3.11.2013, 16:22:33 ) *
no wrzuć i sprawdzić co zwraca bo skoro wykonuje warunek:
  1. if(!$ck[1]) {
  2. Incorrect or used activation key.
  3. ';
  4. }

no to pewnie $ck[1] nie istnieje smile.gif


Tak ale w które dokładnie miejsce mam wrzucić ten kod?
Go to the top of the page
+Quote Post
com
post 3.11.2013, 16:25:10
Post #8





Grupa: Zarejestrowani
Postów: 3 034
Pomógł: 366
Dołączył: 24.05.2012

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


przed tym warunkiem smile.gif
Go to the top of the page
+Quote Post
JacobGames26
post 3.11.2013, 16:28:22
Post #9





Grupa: Zarejestrowani
Postów: 37
Pomógł: 0
Dołączył: 12.10.2013

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


Cytat(com @ 3.11.2013, 16:25:10 ) *
przed tym warunkiem smile.gif


tutaj ?

  1. var_dump($ck[1]);
  2. if(!$ck[1]) {
  3. echo 'Incorrect or used activation key. '.$key;
  4. }
Go to the top of the page
+Quote Post
com
post 3.11.2013, 16:32:06
Post #10





Grupa: Zarejestrowani
Postów: 3 034
Pomógł: 366
Dołączył: 24.05.2012

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


tak smile.gif a potem pokaż wynik, może lepiej tak
  1. var_dump($ck);
  2. if(!$ck[1]) {
  3. echo 'Incorrect or used activation key. '.$key;
  4. }
Go to the top of the page
+Quote Post
JacobGames26
post 3.11.2013, 16:35:32
Post #11





Grupa: Zarejestrowani
Postów: 37
Pomógł: 0
Dołączył: 12.10.2013

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


Cytat(com @ 3.11.2013, 16:32:06 ) *
tak smile.gif a potem pokaż wynik, może lepiej tak
  1. var_dump($ck);
  2. if(!$ck[1]) {
  3. echo 'Incorrect or used activation key. '.$key;
  4. }



Oto wynik "bool(false) Incorrect or used activation key. 52766d1c5a64c"
Go to the top of the page
+Quote Post
pedro84
post 3.11.2013, 16:38:21
Post #12





Grupa: Nieautoryzowani
Postów: 2 249
Pomógł: 305
Dołączył: 2.10.2006

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


To już wiesz czemu - rekord nie istnieje więc warunek jest spełniony, stąd błąd.


--------------------
Google knows the answer...
Go to the top of the page
+Quote Post
JacobGames26
post 3.11.2013, 16:39:34
Post #13





Grupa: Zarejestrowani
Postów: 37
Pomógł: 0
Dołączył: 12.10.2013

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


Cytat(pedro84 @ 3.11.2013, 16:38:21 ) *
To już wiesz czemu - rekord nie istnieje więc warunek jest spełniony, stąd błąd.


Dobrze. A jak owe warunek naprawić?
Go to the top of the page
+Quote Post
pedro84
post 3.11.2013, 16:44:33
Post #14





Grupa: Nieautoryzowani
Postów: 2 249
Pomógł: 305
Dołączył: 2.10.2006

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


Spróbuj tak:
  1. if(isset($key)) {
  2. $checkkey = 'SELECT id FROM users WHERE activation_key="'.$key.'"';
  3. $ck = mysql_fetch_row(mysql_query($checkkey));
  4. if(!$ck[0]) {
  5. Incorrect or used activation key.
  6. ';
  7. }


Sprawdź też zmienną $key:
  1. var_dump($key);


Ten post edytował pedro84 3.11.2013, 16:44:44


--------------------
Google knows the answer...
Go to the top of the page
+Quote Post
JacobGames26
post 3.11.2013, 16:46:45
Post #15





Grupa: Zarejestrowani
Postów: 37
Pomógł: 0
Dołączył: 12.10.2013

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


Cytat(pedro84 @ 3.11.2013, 16:44:33 ) *
Spróbuj tak:
  1. if(isset($key)) {
  2. $checkkey = 'SELECT id FROM users WHERE activation_key="'.$key.'"';
  3. $ck = mysql_fetch_row(mysql_query($checkkey));
  4. if(!$ck[0]) {
  5. Incorrect or used activation key.
  6. ';
  7. }


Sprawdź też zmienną $key:
  1. var_dump($key);


Owy błąd nadal występuje.

Gdzie wkleić var_dump($key);?
Go to the top of the page
+Quote Post
pedro84
post 3.11.2013, 16:51:08
Post #16





Grupa: Nieautoryzowani
Postów: 2 249
Pomógł: 305
Dołączył: 2.10.2006

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


Przed zapytanie. Ja naprawdę poleciłbym Ci poczytać manual, bo nie znasz absolutnie żadnych podstaw.


--------------------
Google knows the answer...
Go to the top of the page
+Quote Post
JacobGames26
post 3.11.2013, 17:28:34
Post #17





Grupa: Zarejestrowani
Postów: 37
Pomógł: 0
Dołączył: 12.10.2013

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


Cytat(pedro84 @ 3.11.2013, 16:51:08 ) *
Przed zapytanie. Ja naprawdę poleciłbym Ci poczytać manual, bo nie znasz absolutnie żadnych podstaw.


No muszę przyznać ze nie znam . Owy manual gdzie można znaleść?
Go to the top of the page
+Quote Post
com
post 3.11.2013, 17:42:56
Post #18





Grupa: Zarejestrowani
Postów: 3 034
Pomógł: 366
Dołączył: 24.05.2012

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


http://php.net wink.gif

Ten post edytował com 3.11.2013, 17:43:09
Go to the top of the page
+Quote Post
JacobGames26
post 3.11.2013, 17:54:21
Post #19





Grupa: Zarejestrowani
Postów: 37
Pomógł: 0
Dołączył: 12.10.2013

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


Cytat(com @ 3.11.2013, 17:42:56 ) *


Jest może jakaś polska strona ? biggrin.gif
Go to the top of the page
+Quote Post
com
post 3.11.2013, 18:06:04
Post #20





Grupa: Zarejestrowani
Postów: 3 034
Pomógł: 366
Dołączył: 24.05.2012

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


http://www.php.net/manual/pl/

ale bez jaj jak chcesz programować to musisz znać ang smile.gif
Go to the top of the page
+Quote Post

2 Stron V   1 2 >
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: 7.07.2025 - 13:56