Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php/mysql] problem z skryptem logowania
Majcok12
post
Post #1





Grupa: Zarejestrowani
Postów: 54
Pomógł: 0
Dołączył: 20.02.2004

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


Mam problem z systemem newsow, tzn. zrobilem link "wiecej" w ktorym bedzie zawarta dalsza czesc newsa i tu jest problem, gdyz gdy klikam wiecej w obojetnie jakim newsie zawsze w stronie, ktora sie otworzy jest dalsza czesc newsa, ale ostatniego, ktory jest pobierany z bazy danych i nie wiem jak sobie z tym poradzic.
ponizej kod skryptu:
  1. <?php
  2. include &#092;"common.php\";
  3.  
  4. global $id_polaczenia;
  5. $id_polaczenia = db_connect();
  6. if(!$id_polaczenia) error_message(sql_error());
  7.  
  8. html_header();
  9. echo &#092;"<TR>n\";
  10. echo &#092;"<TD WIDTH=\"100%\" HEIGHT=\"16\" background=\"layout/belka2.gif\" style=\"border-bottom: solid; border-bottom-width: 1px; border-bottom-color: black;\"><center><font style=\"font-family: Times New Roman; font-size: 8pt;\"><b>News</b></center></TD>n\";
  11. echo &#092;"</TR>n\";
  12. echo &#092;"</table>n\";
  13. echo &#092;"<TABLE BORDER=\"0\" cellpadding=\"1\" cellspacing=\"0\" WIDTH=\"100%\" HEIGHT=\"1200\" BGCOLOR=\"#000000\" style=\"border-left: solid; border-left-width: 1px; border-left-color: black; border-bottom: solid; border-bottom-width: 1px; border-bottom-color: black; border-right: solid; border-right-width: 1px; border-right-color: black;\">n\";
  14. echo &#092;" <TR>n\";
  15. echo &#092;"  <TD valign=\"top\" align=\"left\" bgcolor=\"#414141\" colspan=\"3\">n\";
  16. echo &#092;"<br>n\";
  17.  
  18. $query = &#092;"SELECT news_headline, add_ndate, autor, news_contents, more, news_id, edit_
    n
  19. m FROM news ORDER BY news_num DESC LIMIT 0, 6\";
  20. $wynik = mysql_query($query);
  21. if(!$wynik) error_message(sql_error());
  22.  
  23. while ($q_data = mysql_fetch_array($wynik)) {
  24.     $naglowek = $q_data[\"news_headline\"];
  25.     $data = $q_data[\"add_ndate\"];
  26.     $autor = $q_data[\"autor\"];
  27.     $zawartosc_p = $q_data[\"news_contents\"];
  28.     $zawartosc_k = $q_data[\"more\"];
  29.     $id_news = $q_data[\"news_id\"];
  30.     $edit_n = $q_data[\"edit_num\"];
  31.  
  32. echo \"<font style=\"margin-left: 5pt; font-family: Verdana; font-size: 9pt; color: gray;\"><b> $naglowek </b><br>n\";
  33. echo \"<font style=\"margin-left: 5pt; font-family: Verdana; font-size: 9px; color: darkgray;\"> $data <br>n\";
  34.  
  35. echo \" <table border=\"0\" cellpadding=\"1\" cellspacing=\"0\" width=\"480\">n\";
  36. echo \" <tr>n\";
  37. echo \" <td align=\"center\" width=\"480\">n\";
  38. echo \"   <table border=\"0\" cellpadding=\"1\" cellspacing=\"0\" width=\"450\">n\";
  39. echo \"    <tr>n\";
  40. echo \"     <td align=\"center\" width=\"450\">n\";
  41. echo \"      <DIV ALIGN=\"justify\">n\";
  42. echo \"<font style=\"font-family: Verdana; font-size: 10px; color: gray;\">n\";
  43. echo \"$zawartosc_p n\";
  44. echo \"            </div>n\";
  45. echo \"          </td>n\";
  46. echo \"        </tr>n\";
  47. echo \"     </table>n\";
  48. echo \" </td>n\";
  49. echo \" </tr>n\";
  50. echo \" <tr>n\";
  51. echo \" <td align=\"left\" with\"480\">n\";
  52. echo \" &nbsp;<a target=\"blank\" href=\"index.php?action=view_r&id_news=$id_news\"><font style=\"font-family: Verdana; font-size: 9px;\"><i>Wiecej</i></a><br>n\";
  53. if(!$edit_n == 0) {
  54. echo \" &nbsp;&nbsp;&nbsp;<font style=\"font-family: Verdana; font-size: 9px;\"><i>Edytowano $edit_n razy</i><br>n\";
  55. }
  56. echo \" </td>n\";
  57. echo \" </tr>n\";
  58. echo \" </table>n\";
  59.  
  60. echo \"<center>n\";
  61. echo \"<img src=\"layout/l.jpg\">n\";
  62. echo \"</center>n\";
  63. echo \"<br>n\";
  64. }
  65. echo \"</td>n\";
  66. echo \"</TR>n\";
  67. echo \"</TABLE>n\";
  68. html_footer();
  69.  
  70. function view_r() {
  71.     global $id_news;
  72.     $query = \"SELECT news_headline, add_ndate, autor, news_contents, more, edit_num FROM n
  73. ws WHERE news_id = '$id_news'\";
  74.     $wynik = mysql_query($query);
  75.     if(!$wynik) error_message(sql_error());
  76.     $q_data = mysql_fetch_array($wynik);
  77.  
  78.     $naglowek = $q_data[\"news_headline\"];
  79.     $data = $q_data[\"add_ndate\"];
  80.     $autor = $q_data[\"autor\"];
  81.     $zawartosc_p = $q_data[\"news_contents\"];
  82.     $zawartosc_k = $q_data[\"more\"];
  83.     $edit_n = $q_data[\"edit_num\"];
  84.  
  85.     html_header();
  86. echo \"<TR>n\";
  87. echo \"<TD WIDTH=\"100%\" HEIGHT=\"16\" background=\"layout/belka2.gif\" style=\"border-bottom: solid; border-bottom-width: 1px; border-bottom-color: black;\"><center><font style=\"font-family: Times New Roman; font-size: 8pt;\"><b>News</b></center></TD>n\";
  88. echo \"</TR>n\";
  89. echo \"</table>n\";
  90. echo \"<TABLE BORDER=\"0\" cellpadding=\"1\" cellspacing=\"0\" WIDTH=\"100%\" HEIGHT=\"1200\" BGCOLOR=\"#000000\" style=\"border-left: solid; border-left-width: 1px; border-left-color: black; border-bottom: solid; border-bottom-width: 1px; border-bottom-color: black; border-right: solid; border-right-width: 1px; border-right-color: black;\">n\";
  91. echo \" <TR>n\";
  92. echo \"  <TD valign=\"top\" align=\"left\" bgcolor=\"#414141\" colspan=\"3\">n\";
  93. echo \"<br>n\";
  94.  
  95. echo \"<font style=\"margin-left: 5pt; font-family: Verdana; font-size: 9pt; color: gray;\"><b> $naglowek </b><br>n\";
  96. echo \"<font style=\"margin-left: 5pt; font-family: Verdana; font-size: 9px; color: darkgray;\"> $data <br>n\";
  97.  
  98. echo \" <table border=\"0\" cellpadding=\"1\" cellspacing=\"0\" width=\"480\">n\";
  99. echo \" <tr>n\";
  100. echo \" <td align=\"center\" width=\"480\">n\";
  101. echo \"   <table border=\"0\" cellpadding=\"1\" cellspacing=\"0\" width=\"450\">n\";
  102. echo \"    <tr>n\";
  103. echo \"     <td align=\"center\" width=\"450\">n\";
  104. echo \"      <DIV ALIGN=\"justify\">n\";
  105. echo \"<font style=\"font-family: Verdana; font-size: 10px; color: gray;\">n\";
  106. echo \"$zawartosc_p  <br><br>n\";
  107. echo \"$zawartosc_k n\";
  108. echo \"            </div>n\";
  109. echo \"          </td>n\";
  110. echo \"        </tr>n\";
  111. echo \"     </table>n\";
  112. echo \" </td>n\";
  113. echo \" </tr>n\";
  114. if(!$edit_n == 0) {
  115. echo \" <tr>n\";
  116. echo \" <td align=\"left\" with\"480\">n\";
  117. echo \" &nbsp;&nbsp;&nbsp;<font style=\"font-family: Verdana; font-size: 9px;\"><i>Edytowano $edit_n razy</i><br>n\";
  118. echo \" </td>n\";
  119. echo \" </tr>n\";
  120. }
  121. echo \" </table>n\";
  122.  
  123. echo \"<center>n\";
  124. echo \"<img src=\"layout/l.jpg\">n\";
  125. echo \"</center>n\";
  126. echo \"<br>n\";
  127. echo \"</td>n\";
  128. echo \"</TR>n\";
  129. echo \"</TABLE>n\";
  130. html_footer();
  131.  
  132.  
  133.  
  134. }
  135.  
  136. switch($action) {
  137.     case \"view_r\";
  138.     view_r();
  139.     break;
  140. }
  141.  
  142. ?>



Prosze o pomoc.

Pzdr

Ten post edytował Majcok12 20.10.2004, 18:13:40
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Majcok12
post
Post #2





Grupa: Zarejestrowani
Postów: 54
Pomógł: 0
Dołączył: 20.02.2004

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


Wykorzystalem twoj pomysl, ale pewnie cos zle zrobielm, bo nie dziala.
kod funkcji log_form() (wyswietla formularz logowania)
  1. <?
  2. function log_form() {
  3. html_header();
  4. ?>
  5.  </TR>
  6.  <TR>
  7. <TD WIDTH=\"100%\" HEIGHT=\"16\" background=\"layout/belka2.gif\" style=\"border-bottom: solid; border-bottom-width: 1px; border-bottom-color: black;\"><center><font style=\"font-family: Times New Roman; font-size: 8pt;\"><b>Logowanie</b></center></TD>
  8.  
  9.  </TR>
  10. </table>
  11. <TABLE cellpadding=\"1\" cellspacing=\"0\" WIDTH=\"100%\" HEIGHT=\"1000\" BGCOLOR=\"#000000\" style=\"border-left: solid; border-left-width: 1px; border-left-color: black; border-bottom: solid; border-bottom-width: 1px; border-bottom-color: black; border-right: solid; border-right-width: 1px; border-right-color: black;\">
  12.  <TR>
  13. <TD valign=\"top\" align=\"center\" bgcolor=\"#414141\" colspan=\"3\">
  14. <br>
  15. <form method=\"post\" action=\"<?php echo $PHP_SELF ?>\">
  16. <table border=\"0\" cellpadding=\"1\" cellspacing=\"0\" width=\"95%\" height=\"10%\" align=\"center\" valign=\"top\">
  17.  <tr>
  18. <th width=\"30%\" NOWRAP><font style=\"font-family: Verdana; font-size: 10px; color: gray;\">Nick:</th>
  19. <td width=\"70%\"><input type=\"text\" name=\"user_nick\" size=\"20\" maxlenght=\"20\" class=\"pollItem\"></td>
  20.  </tr> 
  21.  <tr>
  22. <th width=\"30%\" NOWRAP><font style=\"font-family: Verdana; font-size: 10px; color: gray;\">Hasło:</th>
  23. <td width=\"70%\"><input type=\"text\" name=\"user_password\" size=\"20\" maxlenght=\"20\" class=\"pollItem\"></td>
  24.  </tr> 
  25.  <tr>
  26. <th width=\"30%\" colspan=\"2\" NOWRAP>
  27. <input type=\"submit\" class=\"pollButton\" value=\"Zaloguj\" onmouseover=\"this.className='pollButton-over'\" onmouseout=\"this.className='pollButton'\">
  28. </tr>
  29.  </table>
  30. </table>
  31.  </form>
  32.  <?php
  33. html_footer();
  34.  
  35. $_SESSION['user_nick\"\"user_password'];
  36. }
  37. ?>


A tu pliku register.php
  1. <?
  2. include(&#092;"common.php\");
  3. global $id_polaczenia;
  4. $id_polaczenia = db_connect();
  5.  
  6. log_form();
  7.  
  8. $zapytanie=mysql_query(&#092;"SELECT user_nick, user_pass FROM users WHERE user_nick ='$_SESSION[user_nick]' AND user_pass ='$_SESSION[user_password]'\");
  9. $user=mysql_fetch_array($zapytanie);
  10. if($_SESSION[&#092;"user_nick\"] == strtolower($user[\"user_nick\"]) && $_SESSION[\"user_password\"] == $user[\"user_pass\"]){
  11.  
  12. global $id_polaczenia;
  13. $id_polaczenia = db_connect();
  14. function in_use($user_nick) {
  15. global $user_tablename;
  16.  
  17. $query = &#092;"SELECT user_nick FROM $user_tablename WHERE user_nick = '$user_nick'\";
  18. $wynik = mysql_query($query);
  19. if(!mysql_num_rows($wynik)) return 0;
  20. else return 1;
  21. }
  22.  
  23. function reg_form() {
  24.  
  25. html_header();
  26. ?>
  27.  </TR>
  28.  <TR>
  29. <TD WIDTH=\"100%\" HEIGHT=\"16\" background=\"layout/belka2.gif\" style=\"border-bottom: solid; border-bottom-width: 1px; border-bottom-color: black;\"><center><font style=\"font-family: Times New Roman; font-size: 8pt;\"><b>Dodaj nowego użytkownika</b></center></TD>
  30.  
  31.  </TR>
  32. </table>
  33. <TABLE cellpadding=\"1\" cellspacing=\"0\" WIDTH=\"100%\" HEIGHT=\"1000\" BGCOLOR=\"#000000\" style=\"border-left: solid; border-left-width: 1px; border-left-color: black; border-bottom: solid; border-bottom-width: 1px; border-bottom-color: black; border-right: solid; border-right-width: 1px; border-right-color: black;\">
  34.  <TR>
  35. <TD valign=\"top\" align=\"center\" bgcolor=\"#414141\" colspan=\"3\">
  36. <br>
  37. <form method=\"post\" enctype=\"multipart/form-data\" action=\"<?php echo $PHP_SELF ?>\">
  38. <input type=\"hidden\" name=\"action\" value=\"register\">
  39.  
  40. <table border=\"0\" cellpadding=\"1\" cellspacing=\"0\" width=\"95%\" height=\"70%\" align=\"center\" valign=\"top\">
  41.  <tr>
  42. <th width=\"30%\" NOWRAP><font style=\"font-family: Verdana; font-size: 10px; color: gray;\">Nick:</th>
  43. <td width=\"70%\">&nbsp; <input type=\"text\" size=\"20\" maxlength=\"20\" name=\"nick\" class=\"pollItem\"></td>
  44.  </tr> 
  45.  <tr>
  46. <th width=\"30%\" NOWRAP><font style=\"font-family: Verdana; font-size: 10px; color: gray;\">Wybrane hasło:</th>
  47. <td width=\"70%\">&nbsp; <input type=\"password\" name=\"userpassword\" size=\"20\" maxlenght=\"20\" class=\"pollItem\"></td>
  48.  </tr>
  49.  <tr>
  50. <th width=\"30%\" NOWRAP><font style=\"font-family: Verdana; font-size: 10px; color: gray;\">Powtórz hasło:</th>
  51. <td width=\"70%\">&nbsp; <input type=\"password\" name=\"userpassword2\" size=\"20\" maxlenght=\"20\" class=\"pollItem\"></td>
  52.  </tr>
  53.  <tr>
  54. <th width=\"30%\" NOWRAP><font style=\"font-family: Verdana; font-size: 10px; color: gray;\">Email:</th>
  55. <td width=\"70%\">&nbsp; <input type=\"text\" name=\"usermail\" size=\"20\" maxlenght=\"40\" class=\"pollItem\"></td>
  56.  </tr>
  57.  <tr>
  58. <th width=\"30%\" NOWRAP><font style=\"font-family: Verdana; font-size: 10px; color: gray;\">O sobie:</th>
  59. <td width=\"70%\">&nbsp;<textarea rows=\"5\" cols=\"40\" name=\"userprofile\" class=\"pollItem\"></textarea></td>
  60.  </tr>
  61.  <tr>
  62. <th width=\"30%\" NOWRAP><font style=\"font-family: Verdana; font-size: 10px; color: gray;\">Sprzęt:</th>
  63. <td width=\"70%\">&nbsp; <input type=\"text\" name=\"userhardware\" size=\"20\" maxlenght=\"40\" class=\"pollItem\"></td>
  64.  </tr>
  65.  <tr>
  66. <th width=\"30%\" NOWRAP><font style=\"font-family: Verdana; font-size: 10px; color: gray;\">Admin:</th>
  67. <td width=\"70%\">&nbsp; <select name=\"admin\" size=1 class=\"pollItem\">
  68. <option selected value=\"NIE\">NIE</option>
  69. <option value=\"TAK\">TAK</option>
  70. </select>
  71. </td>
  72.  </tr>
  73.  <tr>
  74. <th width=\"30%\" colspan=\"2\" NOWRAP>
  75. <input type=\"submit\" class=\"pollButton\" value=\"Rejestruj\" onmouseover=\"this.className='pollButton-over'\" onmouseout=\"this.className='pollButton'\">
  76. <input type=\"reset\" class=\"pollButton\" value=\"Wyczysc\" onmouseover=\"this.className='pollButton-over'\" onmouseout=\"this.className='pollButton'\"></th>
  77.  </tr>
  78. </table>
  79. </table>
  80.  </form>
  81. <?php
  82. html_footer();
  83. }
  84.  
  85. function register_user() {
  86. global $id_polaczenia;
  87. global $nick, $userpassword, $userpassword2, $usermail, $userprofile, $userhardware, $admin;
  88. global $default_db, $user_tablename;
  89. $awatar = &#092;"obrazki/users/none.jpg\";
  90.  
  91. mailcheck($usermail);
  92. if(empty($userprofile)) error_message(&#092;"Brak komentarza!\");
  93. if(empty($usermail)) error_message(&#092;"Brak adresu email!\");
  94. if(empty($nick)) error_message(&#092;"Brak nicku!\");
  95. if(empty($userpassword)) error_message(&#092;"Brak hasla!\");
  96. if(empty($userpassword2)) error_message(&#092;"Musisz powtórzyć hasło!\");
  97. if($userpassword!=$userpassword2)
  98. error_message(&#092;"Podane hasła nie są identyczne\");
  99.  
  100. if(in_use($nick)) 
  101. error_message(&#092;"Wybrany nick jest już zajęty, proszę wybrać inny\");
  102.  
  103. $query = &#092;"INSERT INTO users VALUES(NULL, '$nick', '$userpassword', '$usermail', '$userprofile', curdate(), NULL, '$userhardware', '$awatar', '$admin')\";
  104.  
  105. $wynik = mysql_query($query);
  106. if(!$wynik) error_message(sql_error());
  107.  
  108. html_header();
  109. ?>
  110.  <TR>
  111. <TD WIDTH=\"100%\" HEIGHT=\"16\" background=\"layout/belka2.gif\" style=\"border-bottom: solid; border-bottom-width: 1px; border-bottom-color: black;\"><center><font style=\"font-family: Times New Roman; font-size: 8pt;\"><b>Dodaj nowego użytkownika</b></center></TD>
  112.  
  113.  </TR>
  114. </table>
  115. <TABLE cellpadding=\"1\" cellspacing=\"0\" WIDTH=\"100%\" HEIGHT=\"1000\" BGCOLOR=\"#000000\" style=\"border-left: solid; border-left-width: 1px; border-left-color: black; border-bottom: solid; border-bottom-width: 1px; border-bottom-color: black; border-right: solid; border-right-width: 1px; border-right-color: black;\">
  116.  <TR>
  117. <TD valign=\"top\" align=\"center\" bgcolor=\"#414141\" colspan=\"3\">
  118. <br>
  119. <font style=\"font-family: Verdana; font-size: 9pt; color: gray;\"><b>Użytkownik <?php echo $nick ?> został zarejestrowany</b><br>
  120.  
  121.  </tr>
  122. </table>
  123. <?php 
  124.  html_footer();
  125. }
  126.  
  127. switch($action) {
  128. case &#092;"register\":
  129. register_user();
  130. break;
  131. default:
  132. reg_form();
  133. break;
  134. }
  135. }
  136.  
  137. else{
  138. header(&#092;"Location: $PHP_SELF?msg=Zły login lub hasło\"); exit;
  139. }
  140.  
  141. ?>


PZdr
Go to the top of the page
+Quote Post

Posty w temacie
- Majcok12   [php/mysql] problem z skryptem logowania   16.10.2004, 21:30:44
- - ARJ   więc tak zaczne od drobnej porady: po co utrudnias...   16.10.2004, 21:40:11
- - Majcok12   Lista newsow. A jak by to wygladalo, gdy na stroni...   16.10.2004, 21:51:27
- - ARJ   jak pokazujesz newsa to dajesz np. w jego tytule l...   16.10.2004, 22:19:39
- - Majcok12   Nie wiem, czy dobrze zrozumialem, Zrobilem to tak:...   18.10.2004, 21:04:59
- - Fibolg   Prawdopodobnie masz akurat ustawioną zmienną ID na...   19.10.2004, 07:16:32
- - ARJ   skrypt dałeś niepełny ale chyba wiem o co chodzi. ...   19.10.2004, 12:19:45
- - Majcok12   Cytat(ARJ @ 2004-10-19 13:19:45)skrypt dałeś ...   19.10.2004, 12:53:46
- - ARJ   zaglądnij w ten topic http://forum.php.pl/index.ph...   19.10.2004, 22:40:12
- - Majcok12   Wykorzystalem twoj pomysl, ale pewnie cos zle zrob...   20.10.2004, 09:10:25
- - ARJ   twój kod jest bardziej zaawansowany niż mój. po dł...   20.10.2004, 13:02:43
- - Majcok12   RE: [php/mysql] problem z skryptem logowania   20.10.2004, 17:58:05
- - ARJ   Cytat(Majcok12 @ 2004-10-20 18:58:05)57 [PHP]...   20.10.2004, 19:48:45
- - Majcok12   Zmienilem skrypt tak jak napisales i to samo. Pro...   20.10.2004, 20:20:38
- - ARJ   a jeśli dasz [PHP] pobierz, plaintext <?  ...   20.10.2004, 21:24:21
- - Majcok12   Cytat(ARJ @ 2004-10-20 22:24:21)a jeśli dasz ...   21.10.2004, 20:24:46
- - ARJ   tylko po co wracać na tą stronę? ona loguje tylko ...   22.10.2004, 15:46:15
- - Majcok12   Zapomnialem napisac. Chociaz po podaniu poprawnych...   23.10.2004, 14:36:50


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: 13.10.2025 - 16:22