Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][MYSQL]Edycja danych
Dizzy
post 22.09.2008, 17:19:38
Post #1





Grupa: Zarejestrowani
Postów: 139
Pomógł: 0
Dołączył: 6.09.2008

Ostrzeżenie: (10%)
X----


Oto mój skrypt
  1. <?php
  2. include 'Konfiguracja/Konfiguracja.php';
  3.  
  4. if ($_SESSION['zalogowany'] == '1') {
  5. echo "<form action='index.php?show=konto' method=post>
  6. <br>
  7. <table border=0 cellspacing=1  id=AutoNumber1>
  8. <tr>
  9. <td  colspan=2>
  10. <p align=center>$username & $user_gg & $user_mail</td>
  11. </tr>
  12. <tr>
  13. <td >&nbsp;</td>
  14. <td >&nbsp;</td>
  15. </tr>
  16. <tr>
  17. <td  colspan=2>&nbsp;</td>
  18. </tr>
  19. <tr>
  20. <td  colspan=2>
  21. <p align=center><b>Ustawienia kontaktowe</b></td>
  22. </tr>
  23. <tr>
  24. <td >Gadu-Gad:</td>
  25. <td ><input type=text name=newgg value=\"$user_gg\" size=20></td>
  26. </tr>
  27. <tr>
  28. <td >E-mail:</td>
  29. <td ><input type=text name=newemail value=\"$user_mail\" size=20></td>
  30. </tr>
  31. <tr>
  32. <td  colspan=2>&nbsp;</td>
  33. </tr>
  34. <tr>
  35. <td  colspan=2>
  36. <p align=center><b>Ustawienia hasła</b></td>
  37. </tr>
  38. <tr>
  39. <td >Aktualne hasło:</td>
  40. <td ><input type=text name=password size=20></td>
  41. </tr>
  42. <tr>
  43. <td >&nbsp;</td>
  44. <td >&nbsp;</td>
  45. </tr>
  46. <tr>
  47. <td >Nowe hasło:</td>
  48. <td ><input type=text name=newpassword size=20></td>
  49. </tr>
  50. <tr>
  51. <td >Powtórz nowe hasło:</td>
  52. <td ><input type=text name=newpassword2 size=20></td>
  53. </tr>
  54. <tr>
  55. <td >&nbsp;</td>
  56. <td >&nbsp;</td>
  57. </tr>
  58. <tr>
  59. <td  colspan=2>
  60. <p align=center><input type=submit value=Zapisz name=B1></td>
  61. </tr>
  62. <tr>
  63. <td >&nbsp;</td>
  64. <td >&nbsp;</td>
  65. </tr>
  66. </table>";
  67. } else {
  68. echo "Brak dostępu, zaloguj sie by mieć dostęp.."; }
  69. $password = mysql_query('SELECT * FROM users WHERE user_haslo="'.md5( md5( $password ) ).'"') or die(mysql_error());
  70. if (mysql_num_rows($password) == 1) {
  71. if ($newpassword != $newpassword2) { echo 'Podane hasla nie zgadzaja sie'; } else {
  72.      $newpassword = md5(md5($newpassword));
  73.      $password = md5(md5($password));
  74. $q = "UPDATE users (user_haslo, user_mail, user_gg) VALUES ('$newpassword' , '$newmail' , '$newgg') WHERE user_login='$username' "; // zapisywanie rekordu do bazy
  75.   if (@mysql_query ($q)) {
  76.   echo " Dane zaktualizowane ";
  77. } else {
  78. echo " Błąd bazy danych ";
  79. }
  80. }
  81. } else { echo "Zle haslo"; }
  82. ?></center>
Mógłby ktoś dlamnie poprawić ten skrypt? Gdyż cały czas wyswietla mi "Złe hasło"
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 13)
_olo_1984
post 22.09.2008, 17:59:36
Post #2





Grupa: Zarejestrowani
Postów: 289
Pomógł: 77
Dołączył: 5.08.2006

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


  1. <?php
  2. include 'Konfiguracja/Konfiguracja.php';
  3. // tu jakiś warunek np. isset($_POST['newpassword'])
  4. $password = mysql_query('SELECT * FROM users WHERE user_haslo="'.md5( md5( $_POST['password'] ) ).'"') or die(mysql_error());
  5. if (mysql_num_rows($password) == 1) {
  6.    $row = mysql_fetch_row($password);
  7.    if ($_POST['newpassword'] != $_POST['newpassword2']) {
  8.        echo 'Podane hasla nie zgadzaja sie';
  9.    } else {
  10.        $newpassword = md5(md5($_POST['newpassword']));
  11.        $password = md5(md5($_POST['password']));
  12.        $q = "UPDATE users (user_haslo, user_mail, user_gg) VALUES ('".$_POST['newpassword']."' , '".$_POST['newmail']."' , '".$_POST['newgg']."') WHERE user_login='".$row['username']."'"; // zapisywanie rekordu do bazy
  13.        if (@mysql_query ($q)) {
  14.            echo " Dane zaktualizowane ";
  15.        } else {
  16.            echo " Błąd bazy danych ";
  17.        }
  18.    }
  19. }
  20. else {
  21.    echo "Zle haslo";
  22. }
  23.  
  24. if ($_SESSION['zalogowany'] == '1') {
  25. ?>
  26. <form action='index.php?show=konto' method=post>
  27. <br>
  28. <table border=0 cellspacing=1  id=AutoNumber1>
  29. <tr>
  30. <td  colspan=2>
  31. <p align=center><?=$username;?> & <?=$user_gg;?> & <?=$user_mail;?></td>
  32. </tr>
  33. <tr>
  34. <td >&nbsp;</td>
  35. <td >&nbsp;</td>
  36. </tr>
  37. <tr>
  38. <td  colspan=2>&nbsp;</td>
  39. </tr>
  40. <tr>
  41. <td  colspan=2>
  42. <p align=center><b>Ustawienia kontaktowe</b></td>
  43. </tr>
  44. <tr>
  45. <td >Gadu-Ga:</td>
  46. <td ><input type=text name="newgg" value="<?=$user_gg;?>" size=20></td>
  47. </tr>
  48. <tr>
  49. <td >E-mail:</td>
  50. <td ><input type=text name="newemail" value="<?=$user_mail;?>" size=20></td>
  51. </tr>
  52. <tr>
  53. <td  colspan=2>&nbsp;</td>
  54. </tr>
  55. <tr>
  56. <td  colspan=2>
  57. <p align=center><b>Ustawienia hasła</b></td>
  58. </tr>
  59. <tr>
  60. <td >Aktualne hasło:</td>
  61. <td ><input type=text name="password" size=20></td>
  62. </tr>
  63. <tr>
  64. <td >&nbsp;</td>
  65. <td >&nbsp;</td>
  66. </tr>
  67. <tr>
  68. <td >Nowe hasło:</td>
  69. <td ><input type=text name="newpassword" size=20></td>
  70. </tr>
  71. <tr>
  72. <td >Powtórz nowe hasło:</td>
  73. <td ><input type=text name="newpassword2" size=20></td>
  74. </tr>
  75. <tr>
  76. <td >&nbsp;</td>
  77. <td >&nbsp;</td>
  78. </tr>
  79. <tr>
  80. <td  colspan=2>
  81. <p align=center><input type=submit value=Zapisz name=B1></td>
  82. </tr>
  83. <tr>
  84. <td >&nbsp;</td>
  85. <td >&nbsp;</td>
  86. </tr>
  87. </table>
  88. <?php
  89. } else {
  90.    echo "Brak dostępu, zaloguj sie by mieć dostęp..";
  91. }
  92.  
  93. ?>
  94. </center>


wogóle to można by to jeszcze bardziej poprawić, skąd bierzesz np. dane do formularza ? one są w sesji ? bo to tak troche po omacku ...


--------------------
awake
Go to the top of the page
+Quote Post
Dizzy
post 22.09.2008, 18:46:33
Post #3





Grupa: Zarejestrowani
Postów: 139
Pomógł: 0
Dołączył: 6.09.2008

Ostrzeżenie: (10%)
X----


Nadal pisze "Złe hasło" sad.gif(
Go to the top of the page
+Quote Post
Lion_87
post 22.09.2008, 18:53:06
Post #4





Grupa: Zarejestrowani
Postów: 850
Pomógł: 120
Dołączył: 15.02.2007
Skąd: Łódź

Ostrzeżenie: (10%)
X----


yyyy a moze zmien name inputa z aktualnym haslem

Bo uzywasz 2 razy password

przy inpucie i zapytaniu sql
Go to the top of the page
+Quote Post
Dizzy
post 22.09.2008, 19:28:00
Post #5





Grupa: Zarejestrowani
Postów: 139
Pomógł: 0
Dołączył: 6.09.2008

Ostrzeżenie: (10%)
X----


Ale ja nawet nic niewpisuje i nieklikam i mi pokazuje "Złe hasło"
Go to the top of the page
+Quote Post
Lion_87
post 22.09.2008, 19:47:58
Post #6





Grupa: Zarejestrowani
Postów: 850
Pomógł: 120
Dołączył: 15.02.2007
Skąd: Łódź

Ostrzeżenie: (10%)
X----


Cytat(Dizzy @ 22.09.2008, 20:28:00 ) *
Ale ja nawet nic niewpisuje i nieklikam i mi pokazuje "Złe hasło"


NO i ?

moze zrob tak aby wykonywal sie po wyslaniu formularza a nie razem z wczytaniem strony
Go to the top of the page
+Quote Post
Dizzy
post 22.09.2008, 20:04:40
Post #7





Grupa: Zarejestrowani
Postów: 139
Pomógł: 0
Dołączył: 6.09.2008

Ostrzeżenie: (10%)
X----


A czy mógłbys ty to zrobic?questionmark.gif
Go to the top of the page
+Quote Post
Lion_87
post 22.09.2008, 20:09:03
Post #8





Grupa: Zarejestrowani
Postów: 850
Pomógł: 120
Dołączył: 15.02.2007
Skąd: Łódź

Ostrzeżenie: (10%)
X----


mozesz uzyc if

  1. <?php
  2. if ($newgg)(
  3.  
  4. //tamten caly kod php
  5.  
  6. )
  7. ?>


i popraw ten password
Go to the top of the page
+Quote Post
Dizzy
post 22.09.2008, 20:14:42
Post #9





Grupa: Zarejestrowani
Postów: 139
Pomógł: 0
Dołączył: 6.09.2008

Ostrzeżenie: (10%)
X----


Lion byłbym wdzięczny jakbyś ty to zrobił ;-)
Go to the top of the page
+Quote Post
Lion_87
post 22.09.2008, 20:18:26
Post #10





Grupa: Zarejestrowani
Postów: 850
Pomógł: 120
Dołączył: 15.02.2007
Skąd: Łódź

Ostrzeżenie: (10%)
X----


  1. <?php
  2. include 'Konfiguracja/Konfiguracja.php';
  3.  
  4. if ($_SESSION['zalogowany'] == '1') {
  5. echo "<form action='index.php?show=konto' method=post>
  6. <br>
  7. <table border=0 cellspacing=1  id=AutoNumber1>
  8. <tr>
  9. <td  colspan=2>
  10. <p align=center>$username & $user_gg & $user_mail</td>
  11. </tr>
  12. <tr>
  13. <td >&nbsp;</td>
  14. <td >&nbsp;</td>
  15. </tr>
  16. <tr>
  17. <td  colspan=2>&nbsp;</td>
  18. </tr>
  19. <tr>
  20. <td  colspan=2>
  21. <p align=center><b>Ustawienia kontaktowe</b></td>
  22. </tr>
  23. <tr>
  24. <td >Gadu-Ga:</td>
  25. <td ><input type=text name=newgg value=\"$user_gg\" size=20></td>
  26. </tr>
  27. <tr>
  28. <td >E-mail:</td>
  29. <td ><input type=text name=newemail value=\"$user_mail\" size=20></td>
  30. </tr>
  31. <tr>
  32. <td  colspan=2>&nbsp;</td>
  33. </tr>
  34. <tr>
  35. <td  colspan=2>
  36. <p align=center><b>Ustawienia hasła</b></td>
  37. </tr>
  38. <tr>
  39. <td >Aktualne hasło:</td>
  40. <td ><input type=text name=password size=20></td>
  41. </tr>
  42. <tr>
  43. <td >&nbsp;</td>
  44. <td >&nbsp;</td>
  45. </tr>
  46. <tr>
  47. <td >Nowe hasło:</td>
  48. <td ><input type=text name=newpassword size=20></td>
  49. </tr>
  50. <tr>
  51. <td >Powtórz nowe hasło:</td>
  52. <td ><input type=text name=newpassword2 size=20></td>
  53. </tr>
  54. <tr>
  55. <td >&nbsp;</td>
  56. <td >&nbsp;</td>
  57. </tr>
  58. <tr>
  59. <td  colspan=2>
  60. <p align=center><input type=submit value=Zapisz name=B1></td>
  61. </tr>
  62. <tr>
  63. <td >&nbsp;</td>
  64. <td >&nbsp;</td>
  65. </tr>
  66. </table>";
  67. } else {
  68. echo "Brak dostępu, zaloguj sie by mieć dostęp.."; }
  69.  
  70. if ($newgg)(
  71. // polaczenie z baza tu wstaw
  72. $sql_password = mysql_query('SELECT * FROM users WHERE user_haslo="'.md5( md5( $password ) ).'"') or die(mysql_error());
  73. if (mysql_num_rows($sql_password) == 1) {
  74. if ($newpassword != $newpassword2) { echo 'Podane hasla nie zgadzaja sie'; } else {
  75.     $newpassword = md5(md5($newpassword));
  76.     $password = md5(md5($password));
  77. $q = "UPDATE users (user_haslo, user_mail, user_gg) VALUES ('$newpassword' , '$newmail' , '$newgg') WHERE user_login='$username' "; // zapisywanie rekordu do bazy
  78.  if (@mysql_query ($q)) {
  79.  echo " Dane zaktualizowane ";
  80. } else {
  81. echo " Błąd bazy danych ";
  82. }
  83. }
  84. } else { echo "Zle haslo"; }
  85. )
  86.  
  87.  
  88.  
  89. ?>
  90. </center>
Go to the top of the page
+Quote Post
Dizzy
post 22.09.2008, 21:33:02
Post #11





Grupa: Zarejestrowani
Postów: 139
Pomógł: 0
Dołączył: 6.09.2008

Ostrzeżenie: (10%)
X----


Parse error: syntax error, unexpected ';' in /home/Dizzy/domains/tibiahunter.pdg.pl/public_html/strony/konto.php on line 73
Go to the top of the page
+Quote Post
Lion_87
post 22.09.2008, 21:46:48
Post #12





Grupa: Zarejestrowani
Postów: 850
Pomógł: 120
Dołączył: 15.02.2007
Skąd: Łódź

Ostrzeżenie: (10%)
X----


no wystarczy wstawic srednik

  1. <?php
  2. include 'Konfiguracja/Konfiguracja.php';
  3.  
  4. if ($_SESSION['zalogowany'] == '1') {
  5. echo "<form action='index.php?show=konto' method=post>
  6. <br>
  7. <table border=0 cellspacing=1  id=AutoNumber1>
  8. <tr>
  9. <td  colspan=2>
  10. <p align=center>$username & $user_gg & $user_mail</td>
  11. </tr>
  12. <tr>
  13. <td >&nbsp;</td>
  14. <td >&nbsp;</td>
  15. </tr>
  16. <tr>
  17. <td  colspan=2>&nbsp;</td>
  18. </tr>
  19. <tr>
  20. <td  colspan=2>
  21. <p align=center><b>Ustawienia kontaktowe</b></td>
  22. </tr>
  23. <tr>
  24. <td >Gadu-G:</td>
  25. <td ><input type=text name=newgg value=\"$user_gg\" size=20></td>
  26. </tr>
  27. <tr>
  28. <td >E-mail:</td>
  29. <td ><input type=text name=newemail value=\"$user_mail\" size=20></td>
  30. </tr>
  31. <tr>
  32. <td  colspan=2>&nbsp;</td>
  33. </tr>
  34. <tr>
  35. <td  colspan=2>
  36. <p align=center><b>Ustawienia hasła</b></td>
  37. </tr>
  38. <tr>
  39. <td >Aktualne hasło:</td>
  40. <td ><input type=text name=password size=20></td>
  41. </tr>
  42. <tr>
  43. <td >&nbsp;</td>
  44. <td >&nbsp;</td>
  45. </tr>
  46. <tr>
  47. <td >Nowe hasło:</td>
  48. <td ><input type=text name=newpassword size=20></td>
  49. </tr>
  50. <tr>
  51. <td >Powtórz nowe hasło:</td>
  52. <td ><input type=text name=newpassword2 size=20></td>
  53. </tr>
  54. <tr>
  55. <td >&nbsp;</td>
  56. <td >&nbsp;</td>
  57. </tr>
  58. <tr>
  59. <td  colspan=2>
  60. <p align=center><input type=submit value=Zapisz name=B1></td>
  61. </tr>
  62. <tr>
  63. <td >&nbsp;</td>
  64. <td >&nbsp;</td>
  65. </tr>
  66. </table>";
  67. } else {
  68. echo "Brak dostępu, zaloguj sie by mieć dostęp.."; }
  69.  
  70. if ($newgg)(
  71. // polaczenie z baza tu wstaw
  72. $sql_password = mysql_query("SELECT * FROM users WHERE user_haslo='".md5(md5($password))."'");
  73. if (mysql_num_rows($sql_password) == 1) {
  74. if ($newpassword != $newpassword2) { echo 'Podane hasla nie zgadzaja sie'; } else {
  75.    $newpassword = md5(md5($newpassword));
  76.    $password = md5(md5($password));
  77. $q = "UPDATE users (user_haslo, user_mail, user_gg) VALUES ('$newpassword' , '$newmail' , '$newgg') WHERE user_login='$username' "; // zapisywanie rekordu do bazy
  78. if (@mysql_query ($q)) {
  79. echo " Dane zaktualizowane ";
  80. } else {
  81. echo " Błąd bazy danych ";
  82. }
  83. }
  84. } else { echo "Zle haslo"; }
  85. )
  86.  
  87.  
  88.  
  89. ?>
  90. </center>
Go to the top of the page
+Quote Post
Dizzy
post 22.09.2008, 21:55:02
Post #13





Grupa: Zarejestrowani
Postów: 139
Pomógł: 0
Dołączył: 6.09.2008

Ostrzeżenie: (10%)
X----


Nadal to samo... :-/
Go to the top of the page
+Quote Post
Lion_87
post 22.09.2008, 22:04:25
Post #14





Grupa: Zarejestrowani
Postów: 850
Pomógł: 120
Dołączył: 15.02.2007
Skąd: Łódź

Ostrzeżenie: (10%)
X----


skasuj z kodu
  1. <?php
  2. ?>
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: 14.08.2025 - 07:03