Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] Zmiana hasła użytkownika
BIG_MICHU
post
Post #1





Grupa: Zarejestrowani
Postów: 49
Pomógł: 0
Dołączył: 27.08.2006

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


Czy takie coś zadziałać powinno? Bo u mnie jakoś nie chce.
  1. <?
  2. if ($_SESSION["zalogowany"] == "no")
  3. {
  4. ?>
  5. <table border="0" width="540">
  6. <tr>
  7. <td class="menu" colspan="2"> &nbsp; </td>
  8. </tr>
  9. </table>
  10. <?
  11. }
  12. elseif ($_SESSION["zalogowany"] == "yes") // Funkcje dostepne po zalogowaniu
  13. {
  14. ?>
  15. <form action="index.php?ids=popraw" method="post">
  16. <table border="0" width="540">
  17. <tr>
  18. <td>&nbsp;</td>
  19. </tr>
  20. <tr>
  21. <td class="tekst_nagl" colspan="2"> Zmiana hasła użytkownika: </td>
  22. </tr>
  23. <tr>
  24. <td>&nbsp;</td>
  25. </tr>
  26. <tr>
  27. <td class="tekst"> Poprzednie hasło: </td>
  28. <td><input type="text" name="stare_haslo" size="20" /></td>
  29. </tr>
  30. <tr>
  31. <td class="tekst"> Nowe hasło: </td>
  32. <td><input type="password" name="newpass1" size="20" maxlength="20"/></td>
  33. </tr>
  34. <tr>
  35. <td class="tekst"> Powtórzenie nowego hasła: </td>
  36. <td><input type="password" name="newpass2" size="20" maxlength="20"/></td>
  37. </tr>
  38. <tr>
  39. <td>&nbsp;</td>
  40. </tr>
  41.  <tr>
  42. <td align="center"><input type="submit" value="Zmiana hasła" /></td>
  43. </tr>
  44. <tr>
  45. <td>&nbsp;</td>
  46. </tr>
  47. </table>
  48. </form>
  49. <?
  50. if ($_GET["ids"] == "popraw")
  51. {
  52. ?>
  53. <form action="index.php?ids1=popraw" method="post">
  54. <table border="0" width="540">
  55. <?
  56. $newpass1 = $_POST['newpass1'];
  57. $newpass2 = $_POST['newpass2'];
  58. $login = $_SESSION['login'];
  59. $pytanie = "select * from user where login ='$login'";
  60. $wyslij = mysql_query($pytanie);
  61. $tablica = mysql_fetch_array($wyslij);
  62. $md5newpass = md5($newpass1);
  63. $oldpass = $tablica['haslo'];
  64. if (!$newpass1 || !$newpass2)
  65. {
  66. $_SESSION['komunikat2'] = "<br>Wpisz hasło<br>";
  67. if ($newpass1 != $newpass2)
  68. {
  69. $_SESSION['komunikat2'] = "<br>Hasła powinny być jednakowe.<br>";
  70. if (strlen($newpass1) <|| strlen ($newpass1) > 10)
  71. {
  72. $_SESSION['komunikat2'] = "<br>Hasło powinno mieć od 4 do 10 znaków.<br>";
  73. }
  74. if ($oldpass == $md5newpass)
  75. {
  76. $_SESSION['komunikat2'] = "<br>Po co zmieniać hasło na takie samo?!<br>";
  77. }
  78. else
  79. {
  80. }
  81. }
  82. $pytanie2 = "update users set haslo='$md5newpass' where login='$login'";
  83. $sending = mysql_query($pytanie2);
  84. $_SESSION['komunikat2'] = "<br>Hasło zostało pomyślnie zmienione.<br>";
  85. }
  86. ?>
  87. </table>
  88. </form>
  89. <?
  90. }
  91. }


Przyznaję się że znalazłem jakiegoś gotowca i chciałem go dostosować do siebie, ale... za cienki Bolek jestem.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
BIG_MICHU
post
Post #2





Grupa: Zarejestrowani
Postów: 49
Pomógł: 0
Dołączył: 27.08.2006

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


Z tym error to nie wiem co do mnie mówisz, bo jestem ciemno zielony (IMG:http://forum.php.pl/style_emoticons/default/sad.gif) A co do session_start... to tu mam główny plik

  1. <?
  2. // Plik startowy strony
  3. session_register('zalogowany'); // Status zalogowania
  4. if (!IsSet($_SESSION["zalogowany"]))
  5. {
  6. $_SESSION["zalogowany"] = "no";
  7. }
  8. if (!IsSet($_SESSION["rola"])) // Rola uzytkownika
  9. {
  10. $_SESSION["rola"] = "no";
  11. }
  12. include ("./nagl.php"); // Wstawianie naglowka
  13. ?>
  14. <table border="1" width="800" cellspacing="0" cellpadding="0" align="center">
  15. <tr>
  16. <? // Wstawianie menu gornego menu_g.php
  17.  // Wstawianie menu lewego menu_l.php
  18. // Wstawianie menu prawego menu_p.php
  19. ?>
  20. <td class="uwaga" colspan="3"><? include ("./menu_g.php"); ?></td>
  21. </tr>
  22. <tr>
  23. <?
  24. if (($_SESSION["zalogowany"] == "no") and ($_GET["ids"] == "logowanie"))
  25. {
  26. $tab = mysql_query("SELECT * from users where login='$_POST[login]'");
  27. $tab_wyn= mysql_fetch_array($tab);
  28. if ($tab_wyn[haslo] == md5($_POST["haslo"]))
  29. {
  30. $_SESSION["rola"] = $tab_wyn[rola];
  31. $_SESSION["zalogowany"] = "yes";
  32. $tab1 = "insert into logowania (id_log,id_logina,data_log) values ('','$tab_wyn[id_users]','')";
  33. $tab_wyn1 = mysql_query($tab1,$connection);
  34. ?>
  35. <td width="125" valign="top"><? include ("./menu_l.php"); ?> </td>
  36. <td width="550" class="tekst_nagl" align="center"> Zostałeś zalogowany !!!
  37. <br>
  38. <br>
  39. <br>
  40. <font class="uwaga" size=4>
  41. <?
  42. $dzisiaj = getdate();  //Przypomnienie-komunikat pojawiajacy sie po zalogowaniu
  43. $dzien = $dzisiaj['mday'];
  44. $miesiac = $dzisiaj['mon'];
  45. $pytanie = mysql_query("select * from przypom where dzien_prz='$dzien' and miesi_prz='$miesiac'");
  46. $odpowiedz = mysql_fetch_array($pytanie);
  47. {
  48. echo $odpowiedz[tekst];
  49. }
  50. ?>
  51. </td>
  52. <?
  53. }
  54. else
  55. {
  56. ?>
  57. <td width="125" valign="top"><? include ("./menu_l.php"); ?> </td>
  58. <td width="550" align="center"><a href="./index.php?idl=login" class="uwaga"> ZŁY LOGIN LUB HASŁO !!! WPROWADŹ PONOWNIE !!! </a></td>
  59. <?
  60. }
  61. }
  62. elseif (($_SESSION["zalogowany"] == "no") and ($_GET["idl"] <> "login"))
  63. {
  64. ?>
  65. <td width="125" valign="top"><? include ("./menu_l.php"); ?> </td>
  66. <td width="550"> &nbsp; </td>
  67. <?
  68. }
  69. elseif (($_SESSION["zalogowany"] == "no") and ($_GET["idl"] == "login"))
  70. {
  71. ?>
  72. <td width="125" valign="top"><? include ("./menu_l.php"); ?> </td>
  73. <td width="550"> <? include ("./login.php"); ?> </td>
  74. <?
  75. }
  76. elseif (($_SESSION["zalogowany"] == "yes") and ($_GET["idl"] == "login"))
  77. {
  78. ?>
  79. <td width="125" valign="top"><? include ("./menu_l.php"); ?> </td>
  80. <td width="550" class="uwaga" align="center"> JESTEŚ JUŻ ZALOGOWANY !!! </td>
  81. <?
  82. }
  83. elseif (($_SESSION["zalogowany"] == "yes") and ($_GET["idl"] == "popraw")) //Poprawianie hasla uzytkownika
  84. {
  85. ?>
  86. <td width="125" valign="top"><? include ("./menu_l.php"); ?> </td>
  87. <td width="550"> <? include ("./popraw.php"); ?> </td>
  88. <?
  89. }
  90. elseif (($_SESSION["zalogowany"] == "yes") and ($_GET["idl"] == "wylogowanie"))
  91. {
  92. ?>
  93. <td width="125" valign="top"><? include ("./menu_l.php"); ?> </td>
  94. <td width="550" class="tekst_nagl" align="center"> Zostałeś wylogowany !!! </td>
  95. <?
  96. $_SESSION["zalogowany"] = "no";
  97. }
  98. elseif ($_SESSION["zalogowany"] == "yes")
  99. {
  100. ?>
  101. <td width="125" valign="top"><? include ("./menu_l.php"); ?> </td>
  102. <td width="550" class="uwaga" align="center"> JESTEŚ JUŻ ZALOGOWANY !!! </td>
  103. <?
  104. }
  105. ?>
  106. <td width="125" valign="top"><? include ("./menu_p.php"); ?> </td>
  107. </tr>
  108. </table>
  109. <table border="0" width="800" cellspacing="0" cellpadding="0" align="center">
  110. <tr>
  111. <td align="center" colspan="3"><a href="./index.php"><img src="./obrazy/powrot.gif" border="0" alt="powrót" /></a></td>
  112. </tr>
  113. <tr>
  114. <td colspan="3" align="center">
  115. <p>
  116. <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="89" border="0" /></a>
  117. </p>
  118. </td>
  119. </tr>
  120. </table>
  121. </body>
  122. </html>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 28.12.2025 - 06:30