Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]logowanie problem
ArturEales
post 24.06.2010, 09:19:45
Post #1





Grupa: Zarejestrowani
Postów: 106
Pomógł: 0
Dołączył: 21.09.2008

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


Witam mam problem ze skryptem logowania. Problem polega na tym że po poprawnym zalogowaniu chciałbym pobrać nazwę użytkownika i przypisać do zmiennej np $user próbowałem tak:


  1. <?php
  2. //plik konfiguracyjny
  3. //Logowanie do Bazy Danych
  4. $connection = @mysql_connect('0', '0', '0');
  5. $db = @mysql_select_db('0', $connection);
  6.  
  7.  
  8. $intTimeoutSeconds = 1800;
  9.  
  10. if(isset($_SESSION['intLastRefreshTime']))
  11. {
  12. if(($_SESSION['intLastRefreshTime']+$intTimeoutSeconds)<time())
  13. {
  14. }
  15. }
  16. $_SESSION['intLastRefreshTime'] = time();
  17.  
  18. if(isset($_POST['logowanie'])) {
  19.  
  20. $dane = @mysql_query('SELECT login, haslo FROM user WHERE login = "'.$_POST['login'].'" AND haslo = "'.$_POST['haslo'].'"') or die(mysql_error());
  21.  
  22. if(mysql_num_rows($dane) == 1) {
  23. $_SESSION['logowanie'] = 'poprawne';
  24. $user = $_POST['login']; //TUTAJ !!!!
  25. } else {
  26. $_SESSION['logowanie'] = 'Błędny login lub hasło!';
  27. }
  28.  
  29. unset($_POST['logowanie']);
  30. }
  31.  
  32. if(isset($_POST['wylogowanie'])) {
  33.  
  34. unset($_SESSION['logowanie']);
  35. unset($_POST['wylogowanie']);
  36. }
  37.  
  38.  
  39. function wyloguj()
  40. {
  41. if($_SESSION['logowanie'] == 'poprawne')
  42. {
  43. $string = '
  44. <style type="text/css" media="screen">
  45. input.submit {
  46. background:url(images/p01.gif) no-repeat #000000;
  47. border:none;
  48. width: 100px;
  49. height: 25px;
  50. color:#FFFFFF;
  51. font-size:14px;
  52. font-weight:700;
  53. font-family:cursive;
  54. }
  55.  
  56. input.submit:hover {
  57. background:url(images/p02.gif) no-repeat #804040;
  58. border:none;
  59. width: 100px;
  60. height: 25px;
  61. color:#FFFFFF;
  62. font-size:14px;
  63. font-weight:700;
  64. font-family:cursive;
  65. }
  66. </style>';
  67.  
  68.  
  69. $string .= '<form action="'.getenv(REQUEST_URI).'" method="post">';
  70. $string .= ' <table>';
  71. $string .= ' <tr>';
  72. $string .= ' <td>';
  73. $string .= ' <input type="submit" name="wylogowanie" value="Wyloguj" class="submit" />';
  74. $string .= ' </td>';
  75. $string .= ' </tr>';
  76. $string .= ' </table>';
  77. $string .= '</form>';
  78. }
  79. return $string;
  80. }
  81.  
  82. function logowanie()
  83. {
  84.  
  85. if($_SESSION['logowanie'] != 'poprawne')
  86. {
  87. $string = '<form action="'.getenv(REQUEST_URI).'" method="post">';
  88. $string .= ' <ul style="list-style-type: none; margin: 0; padding: 0;">';
  89.  
  90. if(isset($_SESSION['logowanie'])) $string .= '<li>'.$_SESSION['logowanie'].'</li>';
  91. $string .= '<style type="text/css" media="screen">
  92. body {
  93. background-color: #90EE90;
  94. font-size: 12px;
  95. font-family: Verdana, Arial, Helvetica, SunSans-Regular, Sans-Serif;
  96. color:#564b47;
  97. padding:0px;
  98. margin:0px;
  99. }
  100. #content {
  101. position:absolute;
  102. height:200px;
  103. width:400px;
  104. margin:-100px 0px 0px -200px;
  105. top: 50%;
  106. left: 50%;
  107. text-align: left;
  108. padding: 1px;
  109. background-color: #FFEBCD;
  110. overflow: auto;
  111. }
  112. p, h1 {
  113. margin: 0px;
  114. padding: 10px;
  115. }
  116. h1 {
  117. font-size: 18px;
  118. color: #FFFAF0;
  119. background-color: #216254;
  120. }
  121. h2 {
  122. font-family: sans-serif;
  123. margin: 0px;
  124. padding: 3px;
  125. font-size: 17px;
  126. color: #404040;
  127. }
  128. </style>';
  129. $string .= '<div id="content">';
  130. $string .= ' <li><center><h1>Logowanie do systemu</h1></center></li>';
  131. $string .= ' <li><center><h2>Login</h2></center><center><input type="text" name="login"/></center></li>';
  132. $string .= ' <li><center><h2>Hasło</h2></center><center><input type="password" name="haslo"/></center></li>';
  133. $string .= ' <li><center><input type="submit" name="logowanie" value="Logowanie"/></center></li>';
  134. $string .= ' </ul>';
  135. $string .= '</form>';
  136. $string .= '</div>';
  137. }
  138. return $string;
  139. }
  140. ?>


no i oczywiście nie działa :/

Ten post edytował ArturEales 24.06.2010, 09:21:24
Go to the top of the page
+Quote Post

Posty w temacie


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: 16.07.2025 - 13:19