Jump to content

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

did you try openeing in append mode?

 

$fh=fopen($scorefile,'a');

 

does the file exist?  after you execute the script you should be able to see the highscores.txt file in the same directory that the script is called from.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.