Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

2 Stron V  < 1 2  
Reply to this topicStart new topic
> wyświetlanie informacji w DIV w zależności od zmiennych PHP
topcio
post 21.11.2017, 13:44:28
Post #21





Grupa: Zarejestrowani
Postów: 140
Pomógł: 0
Dołączył: 14.01.2017

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


zrobiłem na około, jak zwykle smile.gif i wiem zrobiłem to w jguery
dopisałem funkcję entera dla js

  1. $("#form_login").keypress(function(e) {
  2. var keycode = (e.keyCode ? e.keyCode : e.which);
  3. if (keycode == '13') {
  4. LoginTest();
  5. }
  6. });


czy takie coś przejdzie?
Go to the top of the page
+Quote Post
viking
post 21.11.2017, 13:50:26
Post #22





Grupa: Zarejestrowani
Postów: 6 365
Pomógł: 1114
Dołączył: 30.08.2006

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


A po co programować enter zamiast zwykłej wysyłki?

Kod
$("#form_login").on('submit', function(e) {
  e.preventDefault();
  LoginTest();
})


--------------------
Go to the top of the page
+Quote Post
topcio
post 21.11.2017, 13:56:43
Post #23





Grupa: Zarejestrowani
Postów: 140
Pomógł: 0
Dołączył: 14.01.2017

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


bo inaczej nie chce działać jak powinno.
Jest ten button, jak zrobię mu typ submit to wynik otwiera w nowym oknie, ale wówczas działa on jako submit na klawisz enter.
Jeśli usunę mu action, to wynik dostaję zgodnie z zapytaniem ajax (w wyznaczonym div), ale przeładowuje mi cały dokument i wynik znika.

Nie wiem już co robię źle.
Go to the top of the page
+Quote Post
viking
post 21.11.2017, 13:57:55
Post #24





Grupa: Zarejestrowani
Postów: 6 365
Pomógł: 1114
Dołączył: 30.08.2006

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


Pokaż gdzieś cały działający kod bo tak można sobie strzelać.


--------------------
Go to the top of the page
+Quote Post
topcio
post 21.11.2017, 14:08:15
Post #25





Grupa: Zarejestrowani
Postów: 140
Pomógł: 0
Dołączył: 14.01.2017

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


index.php

  1. <?php
  2.  
  3. // Wczytuje potrzebne pliki
  4. require_once 'class/db_login.php';
  5. require_once 'class/Sql.class.php';
  6. require_once 'class/Users.class.php';
  7.  
  8. // Zmienna sesyjna adresu strony
  9. $_SESSION[ 'home_page' ] = "http://topcio.pl";
  10. // Tworzę połączenie z Bazą Danych
  11. $sql = new Sql( $db_host, $db_user, $db_passwd, $db_name );
  12. // Zapisujemy zmienną sesyjną ses_id
  13. $ses_id = session_id();
  14. // Jeśli nie ma utworzonej zmiennej sesyjnej user_id to ustawiamy ją na NULL
  15. if ( !isset( $_SESSION[ 'user_id' ] ) ) {
  16. $_SESSION[ 'user_id' ] = null;
  17. }
  18. // Jeśli zmienna sesyjna wygasła przekierowujemy do strony logowania
  19. if ( $_SESSION[ 'user_id' ] == "null" ) {
  20. header( "Location: index.php?action=log_in" );
  21. }
  22. // Filtrujemy wszystkie zmienne $_POST
  23. if ( !empty( $_POST ) ) {
  24. foreach ( $_POST as $post_value ) {
  25. $post_value = $sql->clear( $post_value );
  26. }
  27. }
  28.  
  29. # RAPORTOWANIE BŁĘDÓW
  30. error_reporting( E_ALL );
  31. ini_set( 'display_errors', 1 );
  32.  
  33. $users = new Users( $sql, $_SESSION[ 'user_id' ] );
  34.  
  35. # WYŚWIETLAMY NAGŁÓWEK STRONY
  36. include 'head.html';
  37. echo "</head>";
  38. echo "<body>";
  39. echo "<div id=\"wall\"></div>";
  40.  
  41. # PRZEŁĄCZNIK STRON
  42. switch ( isset( $_GET[ 'action' ] ) ? $_GET[ 'action' ] : 'user_logged_in' ) {
  43.  
  44. case 'user_logged_in':
  45. $users = new Users( $sql, $_SESSION[ 'user_id' ] );
  46. if ( $users->is_logged() ) {
  47. $data = $users->get_user_data();
  48. $first_login = $users->if_first_login( $data );
  49. if ( $first_login === true ) {
  50. header( "Location: ../index.php?action=first_login" );
  51. } else {
  52. if ( $users->is_there_temp_pass( $data[ 'user_id' ] ) === true ) {
  53. header( "Location: ../index.php?action=login_with_temp_pass" );
  54. } else {
  55. if ( $data[ 'user_range' ] == 1 ) {
  56. header( "Location: ../index.php?action=user_login" );
  57. }
  58. if ( $data[ 'user_range' ] == 2 ) {
  59. header( "Location: ../index.php?action=admin_login" );
  60. }
  61. if ( $data[ 'user_range' ] == 3 ) {
  62. header( "Location: ../index.php?action=devel_login" );
  63. }
  64. }
  65. }
  66. } else {
  67. header( "Location: ../index.php?action=log_in" );
  68. }
  69. break;
  70.  
  71. case 'log_in':
  72. $users->cookie_form();
  73. echo "<div id=\"wrapper\">";
  74. echo "<header>";
  75. echo "<div class=\"login\">";
  76. echo "<div class=\"test\">";
  77. echo "SYSTEM ZARZĄDZANIA MONITORINGIEM";
  78. echo "</div>";
  79. echo "<div class=\"test\">";
  80. echo "<form id=\"form_login\" action=\"../php_function/user_check.php\" enctype=\"multipart/form-data\" method=\"post\">";
  81. echo "<script type=\"text/javascript\"><!--document.write('<input type=\"hidden\" name=\"js\" value=\"1\">');//--></script>";
  82. echo "<noscript><input type=\"hidden\" name=\"js\" value=\"0\"></noscript>";
  83. echo "<span id=\"span_login\">LOGOWANIE</span>";
  84. echo "<div class=\"text_login\">";
  85. echo "<span class=\"login\">Login: </span>";
  86. echo "<input class=\"login\" id=\"input_login\" type=\"text\" placeholder=\"Login\" name=\"user_login\" value=\"" . ( ( isset( $_COOKIE[ 'user_login' ] ) ) ? $_COOKIE[ 'user_login' ] : '' . ( ( isset( $_POST[ 'user_login' ] ) ) ? ( $_POST[ 'user_login' ] ) : '' ) . '' ) . "\">";
  87. echo "</div>";
  88. echo "<div class=\"text_login\">";
  89. echo "<span class=\"login\">Hasło: </span>";
  90. echo "<input class=\"login\" id=\"input_pass\" type=\"password\" placeholder=\"Hasło\" onkeypress=\"capLock(event)\" name=\"user_pass\" value=\"\">";
  91. echo "</div>";
  92. echo "</div>";
  93. echo "<div class=\"test\" id=\"test_001\">";
  94. echo "<span id=\"info\" style=\"visibility:hidden\">INFORMACJA</span>";
  95. echo "<span id=\"login_message_one\"></span>";
  96. echo "</div>";
  97. echo "<div class=\"test\">";
  98. echo "<button id=\"submit\" class=\"submit_button\" type=\"button\" ><span class=\"submit\">LOGIN</span></button>";
  99. echo "</form>";
  100. echo "</div>";
  101. echo "<div class=\"test\" id=\"CapLock\">";
  102. echo "CAPS LOCK IS ON";
  103. echo "</div>";
  104. echo "</div>";
  105. echo "</header>";
  106. echo "</div>";
  107. break;
  108.  
  109. case 'login_with_temp_pass':
  110. if ( empty( $_POST ) ) {
  111. $users->change_temp_pass_form();
  112. } else {
  113. $users->change_temp_pass_form();
  114. printf( implode( '<br />', $users->change_temp_pass() ) );
  115. printf( "<br />" );
  116. printf( "<a href=\"index.php?action=log_out\">Zaloguj się ponownie.</a>" );
  117. }
  118. break;
  119.  
  120. case 'forgetten_confirm':
  121. $forgetten_message = $users->sendForgettenPassword();
  122. echo implode( '<br>', $forgetten_message ) . '</p>';
  123. echo "<a href=\"index.php?action=log_in\">Powrót do strony logowania</a><br />";
  124. break;
  125.  
  126. case 'forgetten':
  127. $users->cookie_form();
  128. if ( !empty( $_POST ) ) {
  129. if ( ( $forgetten_message = $users->forgetten( $_POST ) ) === true ) {
  130. $_SESSION[ 'tablica_post' ] = array();
  131. foreach ( $_POST as $key => $value ) {
  132. $_SESSION[ 'tablica_post' ][ $key ] = $value;
  133. }
  134. $users->forgetten_form_confirm();
  135. } else {
  136. $users->forgetten_form( $forgetten_message );
  137. }
  138. } else {
  139. if ( empty( $_POST ) ) {
  140. $forgetten_message = null;
  141. $users->forgetten_form( $forgetten_message );
  142. }
  143. }
  144. break;
  145.  
  146. case 'user_login':
  147. if ( $users->is_logged() ) {
  148. $data = $users->get_user_data();
  149. if ( $users->is_there_temp_pass( $data[ 'user_id' ] ) === true ) {
  150. header( "Location: index.php?action=login_with_temp_pass" );
  151. }
  152. if ( $data[ 'user_range' ] != 1 ) {
  153. header( "Location: index.php?action=user_logged_in" );
  154. } else {
  155. $data = $users->get_user_data();
  156. echo "USER LOGIN";
  157. foreach ( $data as $sesja => $wartosc ) {
  158. echo "<p>" . $sesja . " = " . $wartosc . "</p>";
  159. }
  160. echo "<a href=\"index.php?action=log_out\">Wyloguj . . .</a>";
  161. }
  162. } else {
  163. header( "Location: index.php?action=user_logged_in" );
  164. }
  165. break;
  166.  
  167. case 'admin_login':
  168. if ( $users->is_logged() ) {
  169. $data = $users->get_user_data();
  170. if ( $users->is_there_temp_pass( $data[ 'user_id' ] ) === true ) {
  171. header( "Location: index.php?action=login_with_temp_pass" );
  172. }
  173. if ( $data[ 'user_range' ] != 2 ) {
  174. header( "Location: index.php?action=user_logged_in" );
  175. } else {
  176. echo "<div id=\"wrapper\"><header>";
  177. $data = $users->get_user_data();
  178. echo "ADMIN LOGIN";
  179. foreach ( $data as $sesja => $wartosc ) {
  180. echo "<p>" . $sesja . " = " . $wartosc . "</p>";
  181. }
  182. echo "<a href=\"index.php?action=log_out\">Wyloguj . . .</a>";
  183. echo "</header></div>";
  184. }
  185.  
  186. } else {
  187. header( "Location: index.php?action=user_logged_in" );
  188. }
  189. break;
  190.  
  191. case 'devel_login':
  192. if ( $users->is_logged() ) {
  193. $data = $users->get_user_data();
  194. if ( $users->is_there_temp_pass( $data[ 'user_id' ] ) === true ) {
  195. header( "Location: index.php?action=login_with_temp_pass" );
  196. }
  197. if ( $data[ 'user_range' ] != 3 ) {
  198. header( "Location: index.php?action=user_logged_in" );
  199. } else {
  200. $data = $users->get_user_data();
  201. echo "SUPER USER LOGIN";
  202. foreach ( $data as $sesja => $wartosc ) {
  203. echo "<p>" . $sesja . " = " . $wartosc . "</p>";
  204. }
  205. echo "<a href=\"index.php?action=log_out\">Wyloguj . . .</a>";
  206. }
  207. } else {
  208. header( "Location: index.php?action=user_logged_in" );
  209. }
  210. break;
  211.  
  212. case 'test':
  213. echo $_SESSION[ 'user_id' ];
  214. break;
  215.  
  216.  
  217. case 'log_out':
  218. if ( $users->is_logged() ) {
  219. $_SESSION[ 'user_id' ] = null;
  220. header( "Location: " . $_SESSION[ 'home_page' ] );
  221. } else {
  222. header( "Location: " . $_SESSION[ 'home_page' ] );
  223. }
  224. break;
  225.  
  226. case 'first_login':
  227. $users->cookie_form();
  228. if ( $users->is_logged() ) {
  229. if ( empty( $_POST ) ) {
  230. $result = null;
  231. $users->first_login_form( $result );
  232. echo "<a href=\"index.php?action=log_out\">Wyloguj . . .</a>";
  233. } else {
  234. $user_id = $users->user_id;
  235. $result = $users->first_login_update( $user_id, $_POST );
  236. $users->first_login_form( $result );
  237. if ( isset( $_SESSION[ 'Update_OK' ] ) ) {
  238. unset( $_SESSION[ 'Update_OK' ] );
  239. header( "Location: index.php?action=log_in" );
  240. } else {
  241. echo "<a href=\"index.php?action=log_out\">Wyloguj . . .</a>";
  242. }
  243. }
  244. } else {
  245. header( "Location: " . $_SESSION[ 'home_page' ] );
  246. }
  247. break;
  248.  
  249. }
  250.  
  251. include 'footer.php';
  252. # ZAMYKAMY POŁĄCZENIE SQL
  253. $sql->close();
  254. ?>




scripts.js
  1. // Funkcja Caps Lock
  2.  
  3. function capLock(data) {
  4. KeyCode = data.keyCode ? data.keyCode : data.which;
  5. ShiftKey = data.shiftKey ? data.shiftKey : ((KeyCode == 16) ? true : false);
  6. if (((KeyCode >= 65 && KeyCode <= 90) && !ShiftKey) || ((KeyCode >= 97 && KeyCode <= 122) && ShiftKey)) {
  7. var elem = ((document.getElementById('CapLock')) ? true : false);
  8. if (elem)
  9. document.getElementById('CapLock').setAttribute('id', "CapLock_ON");
  10. else
  11. var elem1 = ((document.getElementById('CapLock_OFF')) ? true : false);
  12. if (elem1)
  13. document.getElementById('CapLock_OFF').setAttribute('id', "CapLock_ON");
  14. } else
  15. var elem2 = ((document.getElementById('CapLock_ON')) ? true : false);
  16. if (elem2)
  17. document.getElementById('CapLock_ON').setAttribute('id', "CapLock_OFF");
  18. }
  19.  
  20. /*/ Test Logowania
  21. $("#form_login").keypress(function(e) {
  22. var keycode = (e.keyCode ? e.keyCode : e.which);
  23. if (keycode == '13') {
  24. LoginTest();
  25. }
  26. });
  27. */
  28.  
  29. window.onload = function () {
  30. document.getElementById("submit").onclick = function () {
  31. LoginTest();
  32. }
  33. }
  34.  
  35. function LoginTest() {
  36. request = "";
  37. request = new XMLHttpRequest();
  38. var InputLogin = document.getElementById("input_login").value;
  39. var InputPass = document.getElementById("input_pass").value;
  40. var post = "user_login=" + InputLogin + "&user_pass=" + InputPass;
  41. var url = "../php_function/user_check.php";
  42. request.onreadystatechange = LoginTestRequest;
  43. request.open("POST", url, true);
  44. request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  45. request.send(post);
  46. }
  47.  
  48. // Odliczanie czasu do odblokowania loginu
  49.  
  50. id = document.getElementById('user_blocked_time')
  51.  
  52. function odliczaj(id, time_to_unlock) {
  53. seconds = Math.floor(time_to_unlock) % 60;
  54. minutes = Math.floor(time_to_unlock / 60) % 60;
  55. if (time_to_unlock == 0) {
  56. id.innerHTML = "Konto zostało odblokowane";
  57. } else {
  58. var text = "Zbyt wiele nieudanych prób, login został zablokowany <br>" + "Czas do odblokowania:";
  59. id.innerHTML = text + ((minutes < 10) ? '0' + minutes : minutes) + ':' + ((seconds < 10) ? '0' + seconds : seconds);
  60. if (time_to_unlock >= 0) setTimeout(function () {
  61. odliczaj(id, --time_to_unlock)
  62. }, 1000);
  63. }
  64. }
  65.  
  66. function LoginTestRequest() {
  67. if (request.readyState == 4 && request.status == 200) {
  68. var elem = document.getElementById('login_message_one');
  69. if (request.responseText == "User Logged IN") {
  70. window.location = "http://topcio.pl";
  71. }
  72. if (!isNaN(request.responseText)) {
  73. $("#login_message_one").empty();
  74. $("#info").show("slide", { direction: "left" }, 1000);
  75. var time_to_unlock = request.responseText;
  76. var newdiv = document.createElement('div');
  77. newdiv.setAttribute("class", "div_testowy");
  78.  
  79. var script = document.createElement('script');
  80. script.setAttribute("language", "javascript");
  81. script.innerHTML = "odliczaj(user_blocked_time, " + time_to_unlock + ");";
  82. newdiv.appendChild(script);
  83. var newspan = document.createElement('span');
  84. newspan.setAttribute("id", "user_blocked_time");
  85. newdiv.appendChild(newspan);
  86.  
  87. elem.appendChild(newdiv);
  88. } else {
  89. elem.innerHTML = request.responseText;
  90. }
  91. } else {
  92. elem.innerHTML = request.status + " " + request.statusText;
  93. }
  94. }




user_check_php
  1. <?php
  2. require_once '../class/db_login.php';
  3. require_once '../class/Sql.class.php';
  4. require_once '../class/Users.class.php';
  5. // Tworzę połączenie z Bazą Danych
  6. $sql = new Sql( $db_host, $db_user, $db_passwd, $db_name );
  7. // Zapisujemy zmienną sesyjną ses_id
  8. $ses_id = session_id();
  9. // Jeśli nie ma utworzonej zmiennej sesyjnej user_id to ustawiamy ją na NULL
  10. if ( !isset( $_SESSION[ 'user_id' ] ) ) {
  11. $_SESSION[ 'user_id' ] = null;
  12. }
  13. // Filtrujemy wszystkie zmienne $_POST
  14. if ( !empty( $_POST ) ) {
  15. foreach ( $_POST as $post_value ) {
  16. $post_value = $sql->clear( $post_value );
  17. }
  18. }
  19.  
  20. # RAPORTOWANIE BŁĘDÓW
  21. error_reporting( E_ALL );
  22. ini_set( 'display_errors', 1 );
  23.  
  24. $users = new Users( $sql, $_SESSION[ 'user_id' ] );
  25.  
  26. if ( !empty( $_POST ) ) {
  27. loop_0001: $check_user_login = $users->check_user_login( $_POST );
  28. #JEŻELI ISTNIEJE LOGIN W BAZIE
  29. if ( $check_user_login === true ) {
  30. $get_user_id = $users->get_user_id( $_POST );
  31. $info = $users->get_blocked_info( $get_user_id );
  32. # JEŻELI LOGIN ZABLOKOWANY
  33. if ( $info == 1 ) {
  34. if ( $users->login_unlock( $get_user_id ) === true ) {
  35. goto loop_0001;
  36. } else {
  37. if ( is_numeric( $users->get_blocked_time( $get_user_id ) ) ) {
  38. echo $users->get_blocked_time( $get_user_id );
  39. }
  40. }
  41. }
  42. # JEŻELI LOGIN ODBLOKOWANY
  43. if ( $info == 0 ) {
  44. # JEŻELI ISTNIEJE HASŁO TYMCZASOWE
  45. if ( $users->is_there_temp_pass( $get_user_id ) === true ) {
  46. $users->login_form();
  47. # JEŻELI LOGIN/HASŁO NIE SĄ ZGODNE
  48. if ( $users->check_compatibility( $_POST ) === NULL ) {
  49. $users->login_lock( $_POST );
  50. $login_message[] = 'Upewnij się, że wprowadzone dane są poprawne<br />' .
  51. '<a href="../index.php?action=forgetten">Wygeneruj ponownie hasło.</a>';
  52. echo implode( '<br>', $login_message );
  53. }
  54. # JEŻELI LOGIN/HASŁO SĄ ZGODNE
  55. if ( is_numeric( $users->check_compatibility( $_POST ) ) ) {
  56. $_SESSION[ 'user_id' ] = $users->check_compatibility( $_POST );
  57. $users->loged_in( $_SESSION[ 'user_id' ] );
  58. header( "Location: ../index.php?action=login_with_temp_pass" );
  59. }
  60. }
  61. # JEŻELI NIE ISTNIEJE HASŁO TYMCZASOWE
  62. if ( $users->is_there_temp_pass( $get_user_id ) === false ) {
  63. # JEŻELI LOGIN/HASŁO NIE SĄ ZGODNE
  64. if ( $users->check_compatibility( $_POST ) === NULL ) {
  65. $users->login_lock( $_POST );
  66. $login_message[] = "Podany login i/lub hasło są niepoprawne. Spróbuj Ponownie.";
  67. $login_message[] = "<a href=\"../index.php?action=forgetten\">Zapomniałem Hasła.</a>";
  68. echo implode( '<br>', $login_message );
  69. }
  70. # JEŻELI LOGIN/HASŁO SĄ ZGODNE
  71. if ( is_numeric( $users->check_compatibility( $_POST ) ) ) {
  72. $_SESSION[ 'user_id' ] = $users->check_compatibility( $_POST );
  73. $users->loged_in( $_SESSION[ 'user_id' ] );
  74. echo "User Logged IN";
  75.  
  76. }
  77. }
  78. }
  79. }
  80. #JEŻELI NIE ISTNIEJE LOGIN W BAZIE
  81. if ( $check_user_login === false ) {
  82. $get_user_id = null;
  83. $login_message[] = "Podany login i/lub hasło są niepoprawne. Spróbuj Ponownie.";
  84. $login_message[] = "<a href=\"../index.php?action=forgetten\">Zapomniałem Hasła.</a>";
  85. echo implode( '<br>', $login_message );
  86.  
  87. }
  88. }
  89. else if ( empty( $_POST ) ) {
  90. $get_user_id = null;
  91. }
  92.  
  93. ?>
  94.  
Go to the top of the page
+Quote Post
viking
post 21.11.2017, 14:18:31
Post #26





Grupa: Zarejestrowani
Postów: 6 365
Pomógł: 1114
Dołączył: 30.08.2006

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


Chodziło o działający kod na jakimś serwerze. Ale widać że może być problem z zasięgiem zmiennych albo samym wywołaniem js. Co w konsoli przeglądarki jest? Dlaczego raz sesja ma null a niżej sprawdzasz string "null"?


--------------------
Go to the top of the page
+Quote Post
topcio
post 21.11.2017, 14:33:28
Post #27





Grupa: Zarejestrowani
Postów: 140
Pomógł: 0
Dołączył: 14.01.2017

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


działający kod jest na

http://topcio.pl

działanie możesz sprawdzić dla usera topcio_02
Go to the top of the page
+Quote Post
viking
post 21.11.2017, 14:50:08
Post #28





Grupa: Zarejestrowani
Postów: 6 365
Pomógł: 1114
Dołączył: 30.08.2006

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


Konsola, TypeError: elem is undefined line 107
Po wyłaczeniu JS form ma być wysłany na ten sam adres http://topcio.pl/index.php?action=log_in a nie AJAXowy

Ten post edytował viking 21.11.2017, 14:53:19


--------------------
Go to the top of the page
+Quote Post
topcio
post 21.11.2017, 14:53:56
Post #29





Grupa: Zarejestrowani
Postów: 140
Pomógł: 0
Dołączył: 14.01.2017

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


poprawione
Go to the top of the page
+Quote Post
viking
post 21.11.2017, 14:55:47
Post #30





Grupa: Zarejestrowani
Postów: 6 365
Pomógł: 1114
Dołączył: 30.08.2006

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


No i zwraca poprawnie odpowiedź. Jak zamienisz w końcu na submit i poprawisz url to będzie dobrze.


--------------------
Go to the top of the page
+Quote Post
topcio
post 21.11.2017, 14:58:11
Post #31





Grupa: Zarejestrowani
Postów: 140
Pomógł: 0
Dołączył: 14.01.2017

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


zmieniłem na submit, i jak włączony jest javascript to dokument jest przeładowywany po enterze
Go to the top of the page
+Quote Post
viking
post 21.11.2017, 15:03:29
Post #32





Grupa: Zarejestrowani
Postów: 6 365
Pomógł: 1114
Dołączył: 30.08.2006

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


To już ci dawałem kod jaki masz wstawić. I ma być na DOMContentLoaded/$.ready załadowany.


--------------------
Go to the top of the page
+Quote Post
topcio
post 21.11.2017, 23:47:48
Post #33





Grupa: Zarejestrowani
Postów: 140
Pomógł: 0
Dołączył: 14.01.2017

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


Dzięki wielkie, wreszcie to działa i mogę iść dalej smile.gif

viking, a powiedz mi jeszcze jedno.
Zauważyłem, że przy włączonym js. zapytanie jest tak jakby wykonywane 2 razy.
W bazie danych licznik błędnych haseł wskakuje o 2, bez js zalicza o 1. Czy to normalne ?

Jeśli dobrze rozumiem dzieje się tak dlatego, że dodałem tę funkcję preventDefault.
Blokuje ona tylko wyświetlenie dokumentu w nowym oknie, ale i tak się wykonuje w tle?

zmieniłem
e.preventDefault();
na
return false;
i teraz wydaje się być ok

Ten post edytował topcio 21.11.2017, 23:38:51
Go to the top of the page
+Quote Post
viking
post 22.11.2017, 05:56:01
Post #34





Grupa: Zarejestrowani
Postów: 6 365
Pomógł: 1114
Dołączył: 30.08.2006

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


Wykonuje się dlatego że dwa razy przypinasz w kodzie to samo zdarzenie.


--------------------
Go to the top of the page
+Quote Post

2 Stron V  < 1 2
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: 28.03.2024 - 16:55