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
function Sender
( link, number
) {
// Functions
this.request = function( type, url, data ) {
var ask = $.ajax({ // JQuery helper to easy use ajax
type: type, // Type: POST or GET
url: url, // Url: for example "file.php"
data: data // Data: for example { data: value, data2: value2 }
})
.done(function( msg ) { // Runs when the request succeed
console.log( msg );
})
.fail(function( msg ) { // Runs when the request fails
console.log( "Error: " + msg );
});
}
// Globalize functions
var request = this.request;
}
i file.php (czy z kodem wziętym do komentarzy czy bez niego w komentarzach zero efektu)
<?php
{
const linkFileSrc = "./links.txt";
const numberFileSrc = "./numbers.txt";
var $linkFile, $link, $numberFile, $number;
function __construct( $link, $number ) {
$link = $this -> prepareString( $link );
$number = $this -> prepareString( $number );
$this -> number = $number;
$this -> linkFile = fopen( self::linkFileSrc, "a+" ); $this -> numberFile = fopen( self::numberFileSrc, "a+" );
if( $this -> linkFile && $this -> numberFile ) {
if( $this -> check() ) {
}
else {
echo "Link or number is exist already"; }
}
else {
}
}
function __destruct() {
fclose( $this -> numberFile ); }
// function check() {
// while( !feof($this -> file) ) {
// $data = explode("|", fgets($this -> file));
// // Prepare whole strings
// $data[0] = $this -> prepareString( $data[0] );
// $data[1] = $this -> prepareString( $data[1] );
// if( $data[0] == $this -> link ) {
// return false;
// }
// else {
// if( $data[1] == $this -> number ) {
// echo $data[1] . " " . $this -> link;
// return false;
// }
// else {
// return true;
// }
// }
// }
// }
function check() {
$part1 = false;
$part2 = false;
while( !feof($this -> linkFile) ) { $data = fgets($this -> linkFile); $data = $this -> prepareString( $data );
if( $data == $this -> link ) { break;
}
else {
$part1 = true;
break;
}
}
while( !feof($this -> numberFile) ) { $data = fgets($this -> numberFile); $data = $this -> prepareString( $data );
if( $data == $this -> number ) {
break;
}
else {
$part2 = true;
break;
}
}
if( $part1 && $part2 ) {
$this -> write( $this -> linkFile, $this -> link ); $this -> write( $this -> numberFile, $this -> number );
return true;
}
else {
return false;
}
}
// function write() {
// $dataToWrite = $this -> link . "|" . $this -> number;
// fwrite($this -> file, $dataToWrite);
// fwrite($this -> file, PHP_EOL);
// }
function write( $file, $data ) {
}
function prepareString( $string ) {
return $result;
}
}
?>