Jump to content

[SOLVED] Post data from PHP to .txt file...


Huijari

Recommended Posts

Hello can someone tell what is wrong with my code, it should make $player , $highscore in highscore.txt file...

 

<?php
//high score file name
$scorefile='highscore.txt';
// number used same as in encryptor.swf
$n1=1987;
$n2=7;
$n3=15;
$n4=3;
//
$validation=$_POST['validation'];
$highscore=$_POST['highscore'];
$player=$_POST['player'];
// encrypt the score the same way as in encryptor.swf
$val=round(($highscore*$n4-$n3)/$n2+$n1);
$output .= $scorelist[$i]['player'] . ',' . $scorelist[$i]['score'] . "\n";

// check whether the validation value is correct or not
if($validation==$val){
        echo '&valid=1&';
}else{
        echo '&valid=0&'; 
return;
}

// if the validation value is correct, fetch the score list and insert it

$fh=fopen($scorefile, 'w');
fwrite($fh,"$player,$highscore\n");
fclose($fh);

}else{
echo '&valid=0&';	
}
?>

Link to comment
https://forums.phpfreaks.com/topic/168986-solved-post-data-from-php-to-txt-file/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.