Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

5 Stron V   1 2 3 > »   
Reply to this topicStart new topic
> [MySQL][PHP]Przypomnienie Hasla na E-mial-PROBLEM-
swajt
post 24.01.2014, 23:44:58
Post #1





Grupa: Zarejestrowani
Postów: 89
Pomógł: 0
Dołączył: 24.01.2014

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


Siema chcialem dodac do strony zmiana hasla i co z tego mi wyszlo http://cs-rekla.xaa.pl/automat1938/?page=haslo na rzut oka dobrzy wyglonda ale gdy wpisuje dane to wywala warning.
po 1. chcial bym zeby bylo trzeba byc zalogowanym zeby ten plik sie pokazal np zeby pisalo: Nie jestes zalogowany .
po 2. chcial bym zeby dalo rade zmienic haslo.

Prosze o pomoc!!!
A o to Blad Warning
Kod
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/csrekla/public_html/automat1938/strony/haslo.php on line 37
Login Konta lub stare hasło są nie pawidłowe!


Dam wam plik haslo.php.
  1. <?php
  2.  
  3. $polaczenie = @mysql_connect('localhost', 'user', 'haslo')
  4. or die('Brak połączenie z serwerem mysql. B��d: '.mysql_error());
  5.  
  6. $db = @mysql_select_db('baza', $polaczenie)
  7. or die('Nie połączyć sięz bazą danych. Błąd: '.mysql_error());
  8. $wynik = mysql_query("SELECT * FROM poster ORDER BY id ASC")
  9. or die('Błąd zapytania');
  10.  
  11. if(isset($_POST['wyslij'])){
  12. $id = $_POST['id'];
  13. $old = $_POST['old'];
  14. $password = $_POST['pass'];
  15. $rpt_password = $_POST['rpt_pass'];
  16. $db = mysql_select_db("account");
  17.  
  18. $msg['success'] = "Hasło zostało zmienione!";
  19. $msg['not_exist'] = "Login Konta lub stare hasło są nie pawidłowe!";
  20. $msg['not_some'] = "Podane hasła do siebie nie pasujł!";
  21. $msg['pola'] = "Wypełnij Pola !";
  22. if (strlen($old) < 1 || strlen($password) < 1 || strlen($rpt_password) < 1 ){
  23. echo"<p style='color:red;'><b>".$msg['pola']."</b></p>";
  24. }elseif($password!=$rpt_password){
  25. echo"<p style='color:red;'><b>".$msg['not_some']."</b></p>";
  26. }elseif(mysql_num_rows(mysql_query("SELECT * FROM account WHERE login='$id' AND password=PASSWORD('$old')")) > 0){
  27. $update = mysql_query("UPDATE account SET password=PASSWORD('$password') WHERE login='$id'") or die(mysql_error());
  28. }if($update==true){
  29. echo "<p><b>".$msg['success']."</b></p>";
  30. }else{
  31. echo"<p style='color:red;'><b>".$msg['not_exist']."</b></p>";
  32. }
  33.  
  34. }
  35. ?>
  36. <form method='post' action=''>
  37. <table border='0' align='center'>
  38. <tr>
  39. <td>Login: </td><td><input type="text" name="id"></td>
  40. </tr>
  41. <tr>
  42. <td>Stare hasło:</td><td><input type="password" name="old"></td>
  43. </tr>
  44. <tr>
  45. <td>Nowe hasło:</td><td><input type="password" name="pass"></td>
  46. </tr>
  47. <tr>
  48. <td>Powtórz hasło:</td><td><input type="password" name="rpt_pass"></td>
  49. </tr>
  50. <tr>
  51. <td>
  52. <input type="submit" name="wyslij" value="Zmień" />
  53. </td>
  54. </tr>
  55. </table>
  56. </form>


Ten post edytował swajt 25.01.2014, 00:07:07
Powód edycji: [Kshyhoo]: kod umieszczamy w znacznikach PHP a nie CODE
Go to the top of the page
+Quote Post
swajt
post 24.01.2014, 23:55:36
Post #2





Grupa: Zarejestrowani
Postów: 89
Pomógł: 0
Dołączył: 24.01.2014

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


mam dodac plik "haslo.php" ?
Go to the top of the page
+Quote Post
com
post 25.01.2014, 00:01:27
Post #3





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

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


tak miałeś zrobić:
  1. <?php
  2.  
  3. $polaczenie = @mysql_connect('localhost', 'user', 'haslo')
  4. or die('Brak połączenie z serwerem mysql. B��d: '.mysql_error());
  5.  
  6. $db = @mysql_select_db('csrekla_baza', $polaczenie)
  7. or die('Nie połączyć sięz bazą danych. Błąd: '.mysql_error());
  8. $wynik = mysql_query("SELECT * FROM poster ORDER BY id ASC")
  9. or die('Błąd zapytania');
  10.  
  11.  
  12.  
  13. if(isset($_POST['wyslij'])){
  14. $id = $_POST['id'];
  15. $old = $_POST['old'];
  16. $password = $_POST['pass'];
  17. $rpt_password = $_POST['rpt_pass'];
  18. $db = mysql_select_db("account");
  19.  
  20. $msg['success'] = "Hasło zostało zmienione!";
  21. $msg['not_exist'] = "Login Konta lub stare hasło są nie pawidłowe!";
  22. $msg['not_some'] = "Podane hasła do siebie nie pasujł!";
  23. $msg['pola'] = "Wypełnij Pola !";
  24. if (strlen($old) < 1 || strlen($password) < 1 || strlen($rpt_password) < 1 ){
  25. echo"<p style='color:red;'><b>".$msg['pola']."</b></p>";
  26. }elseif($password!=$rpt_password){
  27. echo"<p style='color:red;'><b>".$msg['not_some']."</b></p>";
  28. }elseif(mysql_num_rows(mysql_query("SELECT * FROM account WHERE login='$id' AND password=PASSWORD('$old')")) > 0){
  29. $update = mysql_query("UPDATE account SET password=PASSWORD('$password') WHERE login='$id'") or die(mysql_error());
  30. }if($update==true){
  31. echo "<p><b>".$msg['success']."</b></p>";
  32. }else{
  33. echo"<p style='color:red;'><b>".$msg['not_exist']."</b></p>";
  34. }
  35.  
  36. }
  37. ?>
  38. <form method='post' action=''>
  39. <table border='0' align='center'>
  40. <tr>
  41. <td>Login: </td><td><input type="text" name="id"></td>
  42. </tr>
  43. <tr>
  44. <td>Stare hasło:</td><td><input type="password" name="old"></td>
  45. </tr>
  46. <tr>
  47. <td>Nowe hasło:</td><td><input type="password" name="pass"></td>
  48. </tr>
  49. <tr>
  50. <td>Powtórz hasło:</td><td><input type="password" name="rpt_pass"></td>
  51. </tr>
  52. <tr>
  53. <td>
  54. <input type="submit" name="wyslij" value="Zmień" />
  55. </td>
  56. </tr>
  57. </table>
  58. </form>


Błąd masz tu:
  1. }elseif(mysql_num_rows(mysql_query("SELECT * FROM account WHERE login='$id' AND password=PASSWORD('$old')")) > 0){


sprawdź co zwraca mysql_query("SELECT * FROM account WHERE login='$id' AND password=PASSWORD('$old')") bo jak mniemam zapytanie jest blednę wink.gif

Ten post edytował com 25.01.2014, 00:03:49
Go to the top of the page
+Quote Post
swajt
post 25.01.2014, 00:06:00
Post #4





Grupa: Zarejestrowani
Postów: 89
Pomógł: 0
Dołączył: 24.01.2014

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


czyli co mam zrobic :< questionmark.gif

Najlepiej to by sie przydl nowy skrypt do zmiany hasla sad.gif

Ten post edytował swajt 25.01.2014, 00:08:26
Go to the top of the page
+Quote Post
com
post 25.01.2014, 00:09:32
Post #5





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

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


http://bit.ly/1awhoF8

Błąd wałkowany miliony razy, lub poprostu wystarczyło spojrzeć tu:

http://pl1.php.net/mysql_num_rows
Go to the top of the page
+Quote Post
swajt
post 25.01.2014, 00:13:33
Post #6





Grupa: Zarejestrowani
Postów: 89
Pomógł: 0
Dołączył: 24.01.2014

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


ja i angielski haha.gif ;D

Kurde nwm co jest grane szukalem na necie skryptow zmiany hasla i nic :<
Go to the top of the page
+Quote Post
com
post 25.01.2014, 00:19:45
Post #7





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

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


Jak się chce być programistą to angielski to podstawa wink.gif
http://pippinsplugins.com/change-password-form-short-code/
Go to the top of the page
+Quote Post
swajt
post 25.01.2014, 00:24:37
Post #8





Grupa: Zarejestrowani
Postów: 89
Pomógł: 0
Dołączył: 24.01.2014

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


Sorka ale niechce zostac programistą ,tylko chce dodac do strony zmiane hasla ale jakiegos gotowca tylko zmienic dane do polaczenia i tyle


PROSZE MACIE JAKIES DOBRE SKRYPTY!! :<:<
Go to the top of the page
+Quote Post
com
post 25.01.2014, 00:27:07
Post #9





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

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


no a co masz powyżej? Dałem Ci linka 3 sekundy w google...
Go to the top of the page
+Quote Post
swajt
post 25.01.2014, 00:31:53
Post #10





Grupa: Zarejestrowani
Postów: 89
Pomógł: 0
Dołączył: 24.01.2014

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


Po angielsku jest wiec lipa niewiem co kaman :<
Go to the top of the page
+Quote Post
com
post 25.01.2014, 00:37:02
Post #11





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

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


sciana.gif sciana.gif sciana.gif
http://bit.ly/1awkB7K

a następnym razem nie bierz się za coś czego ie rozumiesz, albo to zleć komuś wink.gif
Go to the top of the page
+Quote Post
swajt
post 25.01.2014, 00:51:28
Post #12





Grupa: Zarejestrowani
Postów: 89
Pomógł: 0
Dołączył: 24.01.2014

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


Niema zadnych skryptow dzialajacych zawsze jakis warning i jakis blad

Widze ze nikt nie pomoze :<
Go to the top of the page
+Quote Post
Turson
post 25.01.2014, 00:53:34
Post #13





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

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


Zawsze jakiś warning, bo nie wystarczy bezmyślnie skopiować, a pomyśleć i zmodyfikować pod własny gust
Go to the top of the page
+Quote Post
swajt
post 25.01.2014, 00:56:51
Post #14





Grupa: Zarejestrowani
Postów: 89
Pomógł: 0
Dołączył: 24.01.2014

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


To podaj dzialajacy skrypt ZMIANY HASLA lub co zrobic zeby ten naprawic co podalem i zeby miec dostep do storny po zalogowaniu "Aby mieć dostęp do tej strony musisz być zalogowany/a."
Go to the top of the page
+Quote Post
com
post 25.01.2014, 01:10:40
Post #15





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

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


no przecież Ci napisałem co masz zrobić, dałem gotowy kod na tej stronie po angielsku .. czego Ty jeszcze chcesz albo się na tym znasz albo zleć to komuś i nie zawracaj głowy...

Ten post edytował com 25.01.2014, 01:12:17
Go to the top of the page
+Quote Post
swajt
post 25.01.2014, 01:21:34
Post #16





Grupa: Zarejestrowani
Postów: 89
Pomógł: 0
Dołączył: 24.01.2014

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


i co to jest niby to??
  1. function pippin_change_password_form() {
  2. global $post;
  3.  
  4. if (is_singular()) :
  5. $current_url = get_permalink($post->ID);
  6. else :
  7. $pageURL = 'http';
  8. if ($_SERVER["HTTPS"] == "on") $pageURL .= "s";
  9. $pageURL .= "://";
  10. if ($_SERVER["SERVER_PORT"] != "80") $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
  11. else $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
  12. $current_url = $pageURL;
  13. endif;
  14. $redirect = $current_url;
  15.  
  16. ob_start();
  17.  
  18. // show any error messages after form submission
  19. pippin_show_error_messages(); ?>
  20.  
  21. <?php if(isset($_GET['password-reset']) && $_GET['password-reset'] == 'true') { ?>
  22. <div class="pippin_message success">
  23. <span><?php _e('Password changed successfully', 'rcp'); ?></span>
  24. </div>
  25. <?php } ?>
  26. <form id="pippin_password_form" method="POST" action="<?php echo $current_url; ?>">
  27. <fieldset>
  28. <p>
  29. <label for="pippin_user_pass"><?php _e('New Password', 'rcp'); ?></label>
  30. <input name="pippin_user_pass" id="pippin_user_pass" class="required" type="password"/>
  31. </p>
  32. <p>
  33. <label for="pippin_user_pass_confirm"><?php _e('Password Confirm', 'rcp'); ?></label>
  34. <input name="pippin_user_pass_confirm" id="pippin_user_pass_confirm" class="required" type="password"/>
  35. </p>
  36. <p>
  37. <input type="hidden" name="pippin_action" value="reset-password"/>
  38. <input type="hidden" name="pippin_redirect" value="<?php echo $redirect; ?>"/>
  39. <input type="hidden" name="pippin_password_nonce" value="<?php echo wp_create_nonce('rcp-password-nonce'); ?>"/>
  40. <input id="pippin_password_submit" type="submit" value="<?php _e('Change Password', 'pippin'); ?>"/>
  41. </p>
  42. </fieldset>
  43. </form>
  44. <?php
  45. return ob_get_clean();
  46. }
Go to the top of the page
+Quote Post
com
post 25.01.2014, 01:27:06
Post #17





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

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


http://phppot.com/php/php-change-password-script/

Źle popatrzyłem tamto było do Wordpress sory wink.gif

Ten post edytował com 25.01.2014, 01:27:20
Go to the top of the page
+Quote Post
swajt
post 25.01.2014, 01:47:25
Post #18





Grupa: Zarejestrowani
Postów: 89
Pomógł: 0
Dołączył: 24.01.2014

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


No I dodalem prawie wszystko gra tylko jak naklikam Zmień bo sobie Spoloszczylem wink.gif to warning ;/
tu macie link do str : http://cs-rekla.xaa.pl/automat1938/?page=haslo

warning:
  1. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/csrekla/public_html/automat1938/strony/haslo.php on line 16
  2. Aktualne hasło jest nieprawidłowe


haslo.php

  1. <?php
  2. $_SESSION["userId"] = "24";
  3. $conn = mysql_connect("localhost","user","haslo");
  4. mysql_select_db("phppot_examples",$conn);
  5. if(count($_POST)>0) {
  6. $result = mysql_query("SELECT *from users WHERE userId='" . $_SESSION["userId"] . "'");
  7. $row=mysql_fetch_array($result);
  8. if($_POST["currentPassword"] == $row["password"]) {
  9. mysql_query("UPDATE users set password='" . $_POST["newPassword"] . "' WHERE userId='" . $_SESSION["userId"] . "'");
  10. $message = "Hasło zostało zmienione";
  11. } else $message = "Aktualne hasło jest nieprawidłowe";
  12. }
  13. ?>
  14. <html>
  15. <head>
  16.  
  17. <link rel="stylesheet" type="text/css" href="styles.css" />
  18. <script>
  19. function validatePassword() {
  20. var currentPassword,newPassword,confirmPassword,output = true;
  21.  
  22. currentPassword = document.frmChange.currentPassword;
  23. newPassword = document.frmChange.newPassword;
  24. confirmPassword = document.frmChange.confirmPassword;
  25.  
  26. if(!currentPassword.value) {
  27. currentPassword.focus();
  28. document.getElementById("currentPassword").innerHTML = "Wymagany";
  29. output = false;
  30. }
  31. else if(!newPassword.value) {
  32. newPassword.focus();
  33. document.getElementById("newPassword").innerHTML = "Wymagany";
  34. output = false;
  35. }
  36. else if(!confirmPassword.value) {
  37. confirmPassword.focus();
  38. document.getElementById("confirmPassword").innerHTML = "Wymagany";
  39. output = false;
  40. }
  41. if(newPassword.value != confirmPassword.value) {
  42. newPassword.value="";
  43. confirmPassword.value="";
  44. newPassword.focus();
  45. document.getElementById("confirmPassword").innerHTML = "Nie ten sam";
  46. output = false;
  47. }
  48. return output;
  49. }
  50. </script>
  51. </head>
  52. <body>
  53. <form name="frmChange" method="post" action="" onSubmit="return validatePassword()">
  54. <div style="width:500px;">
  55. <div class="message"><?php if(isset($message)) { echo $message; } ?></div>
  56. <table border="0" cellpadding="10" cellspacing="0" width="500" align="center" class="tblSaveForm">
  57. <tr class="tableheader">
  58.  
  59. </tr>
  60. <tr>
  61. <td width="40%"><label>Aktualne hasło</label></td>
  62. <td width="60%"><input type="password" name="currentPassword" class="txtField"/><span id="currentPassword" class="required"></span></td>
  63. </tr>
  64. <tr>
  65. <td><label>Nowe hasło</label></td>
  66. <td><input type="password" name="newPassword" class="txtField"/><span id="newPassword" class="required"></span></td>
  67. </tr>
  68. <td><label>Potwierdź hasło</label></td>
  69. <td><input type="password" name="confirmPassword" class="txtField"/><span id="confirmPassword" class="required"></span></td>
  70. </tr>
  71. <tr>
  72. <td colspan="2"><input type="submit" name="submit" value="Zmień" class="btnSubmit"></td>
  73. </tr>
  74. </table>
  75. </div>
  76. </form>
  77. </body></html>


Ten post edytował swajt 25.01.2014, 01:49:02
Go to the top of the page
+Quote Post
Turson
post 25.01.2014, 12:16:09
Post #19





Grupa: Zarejestrowani
Postów: 4 291
Pomógł: 829
Dołączył: 14.02.2009
Skąd: łódź

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


Zobacz, że w zapytaniu brakuje spacji *from i upewnij się, co siedzi w zmiennej $_SESSION['userId']
Go to the top of the page
+Quote Post
swajt
post 25.01.2014, 13:21:46
Post #20





Grupa: Zarejestrowani
Postów: 89
Pomógł: 0
Dołączył: 24.01.2014

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


Niewiem jak sprawdzic

16 linia bledu jest to :


  1. $row=mysql_fetch_array($result);
Go to the top of the page
+Quote Post

5 Stron V   1 2 3 > » 
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: 13.06.2025 - 07:31