Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Brak wyskakujących komunikatów
kubn2
post
Post #1





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 7.11.2014

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


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
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 11)
Pyton_000
post
Post #2





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


Kod
echo var_dump

A to co?
wywal to echo.
Go to the top of the page
+Quote Post
kubn2
post
Post #3





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 7.11.2014

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


Cytat(Pyton_000 @ 7.11.2014, 16:38:12 ) *
Kod
echo var_dump

A to co?
wywal to echo.


Wywalone bez zmian :/
Go to the top of the page
+Quote Post
nospor
post
Post #4





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




nie: echo var_dump(filter_var($link, FILTER_VALIDATE_URL));
a: var_dump($link);
Analogicznie druga zmienna
Go to the top of the page
+Quote Post
kubn2
post
Post #5





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 7.11.2014

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


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 :/
Go to the top of the page
+Quote Post
nospor
post
Post #6





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Nawet to:
echo "Nieprawidłowy link, albo numer!";
ci sie nie wyswietla?
Go to the top of the page
+Quote Post
kubn2
post
Post #7





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 7.11.2014

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


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. ?>


Ten post edytował kubn2 7.11.2014, 17:50:24
Go to the top of the page
+Quote Post
nospor
post
Post #8





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




To ty ten plik odpalasz ajaxem? I dziwisz sie ze w magiczny sposob na ekranie nie widzisz komunikatow?
Go to the top of the page
+Quote Post
kubn2
post
Post #9





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 7.11.2014

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


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ę".
Go to the top of the page
+Quote Post
Pyton_000
post
Post #10





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


Kod
.done(function( msg ) { // Runs when the request succeed
            alert( msg );
        })
Go to the top of the page
+Quote Post
kubn2
post
Post #11





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 7.11.2014

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


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 :/
Go to the top of the page
+Quote Post
Pyton_000
post
Post #12





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


(IMG:style_emoticons/default/sciana.gif) senders.js
Go to the top of the page
+Quote Post

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: 23.08.2025 - 17:17