Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Brak wyskakujących komunikatów
Forum PHP.pl > Forum > PHP
kubn2
Więc mam problem otóż nie wiem dlaczego komunikaty, które powinny wyskakiwać po wypełnieniu formularza nie wyskakują nie wiem gdzie jest błąd pomoże ktoś? Dodam że jak jest wypełnione błędnie to kod się nie wykonuje, ale jak jest poprawnie wypełnione to działa i zapisuje dane do pliku
  1. <?php
  2.  
  3. if( isset($_POST['link']) && isset($_POST['number']) ) {
  4. include_once 'classes/File.php';
  5.  
  6. $link = $_POST['link'];
  7. $number = $_POST['number'];
  8.  
  9. if( filter_var($link, FILTER_VALIDATE_URL) && filter_var($number, FILTER_VALIDATE_INT) ) {
  10. $file = new File( $link, $number );
  11. }
  12. else {
  13. echo "Nieprawidłowy link, albo numer!";
  14. echo var_dump(filter_var($link, FILTER_VALIDATE_URL));
  15. echo var_dump(filter_var($number, FILTER_VALIDATE_INT));
  16. }
  17. }
  18. else {
  19. echo "Musisz podać link i numer!";
  20. }
  21.  
  22. ?>


jak by były potrzebne kody innych plików piszcie ;p
Pyton_000
Kod
echo var_dump

A to co?
wywal to echo.
kubn2
Cytat(Pyton_000 @ 7.11.2014, 16:38:12 ) *
Kod
echo var_dump

A to co?
wywal to echo.


Wywalone bez zmian :/
nospor
nie: echo var_dump(filter_var($link, FILTER_VALIDATE_URL));
a: var_dump($link);
Analogicznie druga zmienna
kubn2
Cytat(nospor @ 7.11.2014, 16:57:04 ) *
nie: echo var_dump(filter_var($link, FILTER_VALIDATE_URL));
a: var_dump($link);
Analogicznie druga zmienna


niestety nadal nic :/
nospor
Nawet to:
echo "Nieprawidłowy link, albo numer!";
ci sie nie wyswietla?
kubn2
nawet to :/ klikam wyślij i nic zero komunikatu jak się pola wypełni źle to nie zapisuje danych na serwerze jak wypełni się dobrze to zapisuje ale komunikatów jak nie było tak nie ma :/

może podeśle jeszcze 2 pliki które wydają mi się że może i tam coś tkwi:

sender.js
  1. function Sender( link, number )
  2. {
  3.  
  4. // Functions
  5. this.request = function( type, url, data ) {
  6. var ask = $.ajax({ // JQuery helper to easy use ajax
  7. type: type, // Type: POST or GET
  8. url: url, // Url: for example "file.php"
  9. data: data // Data: for example { data: value, data2: value2 }
  10. })
  11. .done(function( msg ) { // Runs when the request succeed
  12. console.log( msg );
  13. })
  14. .fail(function( msg ) { // Runs when the request fails
  15. console.log( "Error: " + msg );
  16. });
  17.  
  18. }
  19.  
  20. // Globalize functions
  21. var request = this.request;
  22.  
  23. }


i file.php (czy z kodem wziętym do komentarzy czy bez niego w komentarzach zero efektu)
  1. <?php
  2.  
  3. class File
  4. {
  5. const linkFileSrc = "./links.txt";
  6. const numberFileSrc = "./numbers.txt";
  7.  
  8. var $linkFile, $link, $numberFile, $number;
  9.  
  10. function __construct( $link, $number ) {
  11. $link = $this -> prepareString( $link );
  12. $number = $this -> prepareString( $number );
  13.  
  14. $this -> link = $link;
  15. $this -> number = $number;
  16.  
  17. $this -> linkFile = fopen( self::linkFileSrc, "a+" );
  18. $this -> numberFile = fopen( self::numberFileSrc, "a+" );
  19.  
  20. if( $this -> linkFile && $this -> numberFile ) {
  21. if( $this -> check() ) {
  22. echo "Success";
  23. }
  24. else {
  25. echo "Link or number is exist already";
  26. }
  27. }
  28. else {
  29. echo "File error!";
  30. }
  31. }
  32.  
  33. function __destruct() {
  34. fclose( $this -> linkFile );
  35. fclose( $this -> numberFile );
  36. }
  37.  
  38. // function check() {
  39. // while( !feof($this -> file) ) {
  40. // $data = explode("|", fgets($this -> file));
  41.  
  42. // // Prepare whole strings
  43. // $data[0] = $this -> prepareString( $data[0] );
  44. // $data[1] = $this -> prepareString( $data[1] );
  45.  
  46. // if( $data[0] == $this -> link ) {
  47. // return false;
  48. // }
  49. // else {
  50. // if( $data[1] == $this -> number ) {
  51. // echo $data[1] . " " . $this -> link;
  52. // return false;
  53. // }
  54. // else {
  55. // return true;
  56. // }
  57. // }
  58. // }
  59. // }
  60.  
  61. function check() {
  62. $part1 = false;
  63. $part2 = false;
  64.  
  65. while( !feof($this -> linkFile) ) {
  66. $data = fgets($this -> linkFile);
  67. $data = $this -> prepareString( $data );
  68.  
  69. if( $data == $this -> link ) {
  70. break;
  71. }
  72. else {
  73. $part1 = true;
  74. break;
  75. }
  76. }
  77.  
  78. while( !feof($this -> numberFile) ) {
  79. $data = fgets($this -> numberFile);
  80. $data = $this -> prepareString( $data );
  81.  
  82. if( $data == $this -> number ) {
  83. break;
  84. }
  85. else {
  86. $part2 = true;
  87. break;
  88. }
  89. }
  90.  
  91. if( $part1 && $part2 ) {
  92. $this -> write( $this -> linkFile, $this -> link );
  93. $this -> write( $this -> numberFile, $this -> number );
  94.  
  95. return true;
  96. }
  97. else {
  98. return false;
  99. }
  100. }
  101.  
  102. // function write() {
  103. // $dataToWrite = $this -> link . "|" . $this -> number;
  104.  
  105. // fwrite($this -> file, $dataToWrite);
  106. // fwrite($this -> file, PHP_EOL);
  107. // }
  108.  
  109. function write( $file, $data ) {
  110. fwrite($file, $data);
  111. fwrite($file, PHP_EOL);
  112. }
  113.  
  114. function prepareString( $string ) {
  115. $result = str_replace(' ', '', $string);
  116. $result = str_replace(PHP_EOL, '', $string);
  117.  
  118. return $result;
  119. }
  120.  
  121. }
  122.  
  123. ?>
nospor
To ty ten plik odpalasz ajaxem? I dziwisz sie ze w magiczny sposob na ekranie nie widzisz komunikatow?
kubn2
Cytat(nospor @ 7.11.2014, 17:44:47 ) *
To ty ten plik odpalasz ajaxem? I dziwisz sie ze w magiczny sposob na ekranie nie widzisz komunikatow?


to co zrobić by działał? :/ jestem w kropce tak "trochę".
Pyton_000
Kod
.done(function( msg ) { // Runs when the request succeed
            alert( msg );
        })
kubn2
Cytat(Pyton_000 @ 7.11.2014, 17:58:47 ) *
Kod
.done(function( msg ) { // Runs when the request succeed
            alert( msg );
        })


a tak trochę jaśniej ;p naprawdę nie mam pomysłu na to :/
Pyton_000
sciana.gif senders.js
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.